repoOwner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User) | repoOwner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User) | ||||
session := loginUser(t, repoOwner.Name) | session := loginUser(t, repoOwner.Name) | ||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/comments/%d", | |||||
repoOwner.Name, repo.Name, issue.Index, comment.ID) | |||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments/%d", | |||||
repoOwner.Name, repo.Name, comment.ID) | |||||
req := NewRequestWithValues(t, "PATCH", urlStr, map[string]string{ | req := NewRequestWithValues(t, "PATCH", urlStr, map[string]string{ | ||||
"body": newCommentBody, | "body": newCommentBody, | ||||
}) | }) | ||||
repoOwner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User) | repoOwner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User) | ||||
session := loginUser(t, repoOwner.Name) | session := loginUser(t, repoOwner.Name) | ||||
req := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/issues/%d/comments/%d", | |||||
repoOwner.Name, repo.Name, issue.Index, comment.ID) | |||||
req := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/issues/comments/%d", | |||||
repoOwner.Name, repo.Name, comment.ID) | |||||
session.MakeRequest(t, req, http.StatusNoContent) | session.MakeRequest(t, req, http.StatusNoContent) | ||||
models.AssertNotExistsBean(t, &models.Comment{ID: comment.ID}) | models.AssertNotExistsBean(t, &models.Comment{ID: comment.ID}) |
} | } | ||||
} | } | ||||
}, | }, | ||||
"/repos/{owner}/{repo}/comments/{id}": { | |||||
"delete": { | |||||
"tags": [ | |||||
"issue" | |||||
], | |||||
"summary": "Delete a comment", | |||||
"operationId": "issueDeleteComment", | |||||
"parameters": [ | |||||
{ | |||||
"type": "string", | |||||
"description": "owner of the repo", | |||||
"name": "owner", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "string", | |||||
"description": "name of the repo", | |||||
"name": "repo", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "integer", | |||||
"description": "id of comment to delete", | |||||
"name": "id", | |||||
"in": "path", | |||||
"required": true | |||||
} | |||||
], | |||||
"responses": { | |||||
"204": { | |||||
"$ref": "#/responses/empty" | |||||
} | |||||
} | |||||
}, | |||||
"patch": { | |||||
"consumes": [ | |||||
"application/json" | |||||
], | |||||
"produces": [ | |||||
"application/json" | |||||
], | |||||
"tags": [ | |||||
"issue" | |||||
], | |||||
"summary": "Edit a comment", | |||||
"operationId": "issueEditComment", | |||||
"parameters": [ | |||||
{ | |||||
"type": "string", | |||||
"description": "owner of the repo", | |||||
"name": "owner", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "string", | |||||
"description": "name of the repo", | |||||
"name": "repo", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "integer", | |||||
"description": "id of the comment to edit", | |||||
"name": "id", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"name": "body", | |||||
"in": "body", | |||||
"schema": { | |||||
"$ref": "#/definitions/EditIssueCommentOption" | |||||
} | |||||
} | |||||
], | |||||
"responses": { | |||||
"200": { | |||||
"$ref": "#/responses/Comment" | |||||
} | |||||
} | |||||
} | |||||
}, | |||||
"/repos/{owner}/{repo}/commits/{ref}/statuses": { | "/repos/{owner}/{repo}/commits/{ref}/statuses": { | ||||
"get": { | "get": { | ||||
"produces": [ | "produces": [ | ||||
} | } | ||||
} | } | ||||
}, | }, | ||||
"/repos/{owner}/{repo}/issues/comments/{id}": { | |||||
"delete": { | |||||
"tags": [ | |||||
"issue" | |||||
], | |||||
"summary": "Delete a comment", | |||||
"operationId": "issueDeleteComment", | |||||
"parameters": [ | |||||
{ | |||||
"type": "string", | |||||
"description": "owner of the repo", | |||||
"name": "owner", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "string", | |||||
"description": "name of the repo", | |||||
"name": "repo", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "integer", | |||||
"description": "id of comment to delete", | |||||
"name": "id", | |||||
"in": "path", | |||||
"required": true | |||||
} | |||||
], | |||||
"responses": { | |||||
"204": { | |||||
"$ref": "#/responses/empty" | |||||
} | |||||
} | |||||
}, | |||||
"patch": { | |||||
"consumes": [ | |||||
"application/json" | |||||
], | |||||
"produces": [ | |||||
"application/json" | |||||
], | |||||
"tags": [ | |||||
"issue" | |||||
], | |||||
"summary": "Edit a comment", | |||||
"operationId": "issueEditComment", | |||||
"parameters": [ | |||||
{ | |||||
"type": "string", | |||||
"description": "owner of the repo", | |||||
"name": "owner", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "string", | |||||
"description": "name of the repo", | |||||
"name": "repo", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "integer", | |||||
"description": "id of the comment to edit", | |||||
"name": "id", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"name": "body", | |||||
"in": "body", | |||||
"schema": { | |||||
"$ref": "#/definitions/EditIssueCommentOption" | |||||
} | |||||
} | |||||
], | |||||
"responses": { | |||||
"200": { | |||||
"$ref": "#/responses/Comment" | |||||
} | |||||
} | |||||
} | |||||
}, | |||||
"/repos/{owner}/{repo}/issues/{id}": { | "/repos/{owner}/{repo}/issues/{id}": { | ||||
"get": { | "get": { | ||||
"produces": [ | "produces": [ | ||||
} | } | ||||
} | } | ||||
}, | }, | ||||
"/repos/{owner}/{repo}/issues/{index}/comments/{id}": { | |||||
"delete": { | |||||
"tags": [ | |||||
"issue" | |||||
], | |||||
"summary": "Delete a comment", | |||||
"operationId": "issueDeleteCommentDeprecated", | |||||
"deprecated": true, | |||||
"parameters": [ | |||||
{ | |||||
"type": "string", | |||||
"description": "owner of the repo", | |||||
"name": "owner", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "string", | |||||
"description": "name of the repo", | |||||
"name": "repo", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "integer", | |||||
"description": "this parameter is ignored", | |||||
"name": "index", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "integer", | |||||
"description": "id of comment to delete", | |||||
"name": "id", | |||||
"in": "path", | |||||
"required": true | |||||
} | |||||
], | |||||
"responses": { | |||||
"204": { | |||||
"$ref": "#/responses/empty" | |||||
} | |||||
} | |||||
}, | |||||
"patch": { | |||||
"consumes": [ | |||||
"application/json" | |||||
], | |||||
"produces": [ | |||||
"application/json" | |||||
], | |||||
"tags": [ | |||||
"issue" | |||||
], | |||||
"summary": "Edit a comment", | |||||
"operationId": "issueEditCommentDeprecated", | |||||
"deprecated": true, | |||||
"parameters": [ | |||||
{ | |||||
"type": "string", | |||||
"description": "owner of the repo", | |||||
"name": "owner", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "string", | |||||
"description": "name of the repo", | |||||
"name": "repo", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "integer", | |||||
"description": "this parameter is ignored", | |||||
"name": "index", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"type": "integer", | |||||
"description": "id of the comment to edit", | |||||
"name": "id", | |||||
"in": "path", | |||||
"required": true | |||||
}, | |||||
{ | |||||
"name": "body", | |||||
"in": "body", | |||||
"schema": { | |||||
"$ref": "#/definitions/EditIssueCommentOption" | |||||
} | |||||
} | |||||
], | |||||
"responses": { | |||||
"200": { | |||||
"$ref": "#/responses/Comment" | |||||
} | |||||
} | |||||
} | |||||
}, | |||||
"/repos/{owner}/{repo}/issues/{index}/labels": { | "/repos/{owner}/{repo}/issues/{index}/labels": { | ||||
"get": { | "get": { | ||||
"produces": [ | "produces": [ |
m.Group("/comments", func() { | m.Group("/comments", func() { | ||||
m.Get("", repo.ListRepoIssueComments) | m.Get("", repo.ListRepoIssueComments) | ||||
m.Combo("/:id", reqToken()). | m.Combo("/:id", reqToken()). | ||||
Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueComment) | |||||
Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueComment). | |||||
Delete(repo.DeleteIssueComment) | |||||
}) | }) | ||||
m.Group("/:index", func() { | m.Group("/:index", func() { | ||||
m.Combo("").Get(repo.GetIssue). | m.Combo("").Get(repo.GetIssue). | ||||
m.Group("/comments", func() { | m.Group("/comments", func() { | ||||
m.Combo("").Get(repo.ListIssueComments). | m.Combo("").Get(repo.ListIssueComments). | ||||
Post(reqToken(), bind(api.CreateIssueCommentOption{}), repo.CreateIssueComment) | Post(reqToken(), bind(api.CreateIssueCommentOption{}), repo.CreateIssueComment) | ||||
m.Combo("/:id", reqToken()).Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueComment). | |||||
Delete(repo.DeleteIssueComment) | |||||
m.Combo("/:id", reqToken()).Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueCommentDeprecated). | |||||
Delete(repo.DeleteIssueCommentDeprecated) | |||||
}) | }) | ||||
m.Group("/labels", func() { | m.Group("/labels", func() { |
// EditIssueComment modify a comment of an issue | // EditIssueComment modify a comment of an issue | ||||
func EditIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) { | func EditIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) { | ||||
// swagger:operation PATCH /repos/{owner}/{repo}/comments/{id} issue issueEditComment | |||||
// swagger:operation PATCH /repos/{owner}/{repo}/issues/comments/{id} issue issueEditComment | |||||
// --- | // --- | ||||
// summary: Edit a comment | // summary: Edit a comment | ||||
// consumes: | // consumes: | ||||
// responses: | // responses: | ||||
// "200": | // "200": | ||||
// "$ref": "#/responses/Comment" | // "$ref": "#/responses/Comment" | ||||
editIssueComment(ctx, form) | |||||
} | |||||
// EditIssueCommentDeprecated modify a comment of an issue | |||||
func EditIssueCommentDeprecated(ctx *context.APIContext, form api.EditIssueCommentOption) { | |||||
// swagger:operation PATCH /repos/{owner}/{repo}/issues/{index}/comments/{id} issue issueEditCommentDeprecated | |||||
// --- | |||||
// summary: Edit a comment | |||||
// deprecated: true | |||||
// consumes: | |||||
// - application/json | |||||
// produces: | |||||
// - application/json | |||||
// parameters: | |||||
// - name: owner | |||||
// in: path | |||||
// description: owner of the repo | |||||
// type: string | |||||
// required: true | |||||
// - name: repo | |||||
// in: path | |||||
// description: name of the repo | |||||
// type: string | |||||
// required: true | |||||
// - name: index | |||||
// in: path | |||||
// description: this parameter is ignored | |||||
// type: integer | |||||
// required: true | |||||
// - name: id | |||||
// in: path | |||||
// description: id of the comment to edit | |||||
// type: integer | |||||
// required: true | |||||
// - name: body | |||||
// in: body | |||||
// schema: | |||||
// "$ref": "#/definitions/EditIssueCommentOption" | |||||
// responses: | |||||
// "200": | |||||
// "$ref": "#/responses/Comment" | |||||
editIssueComment(ctx, form) | |||||
} | |||||
func editIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) { | |||||
comment, err := models.GetCommentByID(ctx.ParamsInt64(":id")) | comment, err := models.GetCommentByID(ctx.ParamsInt64(":id")) | ||||
if err != nil { | if err != nil { | ||||
if models.IsErrCommentNotExist(err) { | if models.IsErrCommentNotExist(err) { | ||||
// DeleteIssueComment delete a comment from an issue | // DeleteIssueComment delete a comment from an issue | ||||
func DeleteIssueComment(ctx *context.APIContext) { | func DeleteIssueComment(ctx *context.APIContext) { | ||||
// swagger:operation DELETE /repos/{owner}/{repo}/comments/{id} issue issueDeleteComment | |||||
// swagger:operation DELETE /repos/{owner}/{repo}/issues/comments/{id} issue issueDeleteComment | |||||
// --- | |||||
// summary: Delete a comment | |||||
// parameters: | |||||
// - name: owner | |||||
// in: path | |||||
// description: owner of the repo | |||||
// type: string | |||||
// required: true | |||||
// - name: repo | |||||
// in: path | |||||
// description: name of the repo | |||||
// type: string | |||||
// required: true | |||||
// - name: id | |||||
// in: path | |||||
// description: id of comment to delete | |||||
// type: integer | |||||
// required: true | |||||
// responses: | |||||
// "204": | |||||
// "$ref": "#/responses/empty" | |||||
deleteIssueComment(ctx) | |||||
} | |||||
// DeleteIssueCommentDeprecated delete a comment from an issue | |||||
func DeleteIssueCommentDeprecated(ctx *context.APIContext) { | |||||
// swagger:operation DELETE /repos/{owner}/{repo}/issues/{index}/comments/{id} issue issueDeleteCommentDeprecated | |||||
// --- | // --- | ||||
// summary: Delete a comment | // summary: Delete a comment | ||||
// deprecated: true | |||||
// parameters: | // parameters: | ||||
// - name: owner | // - name: owner | ||||
// in: path | // in: path | ||||
// description: name of the repo | // description: name of the repo | ||||
// type: string | // type: string | ||||
// required: true | // required: true | ||||
// - name: index | |||||
// in: path | |||||
// description: this parameter is ignored | |||||
// type: integer | |||||
// required: true | |||||
// - name: id | // - name: id | ||||
// in: path | // in: path | ||||
// description: id of comment to delete | // description: id of comment to delete | ||||
// responses: | // responses: | ||||
// "204": | // "204": | ||||
// "$ref": "#/responses/empty" | // "$ref": "#/responses/empty" | ||||
deleteIssueComment(ctx) | |||||
} | |||||
func deleteIssueComment(ctx *context.APIContext) { | |||||
comment, err := models.GetCommentByID(ctx.ParamsInt64(":id")) | comment, err := models.GetCommentByID(ctx.ParamsInt64(":id")) | ||||
if err != nil { | if err != nil { | ||||
if models.IsErrCommentNotExist(err) { | if models.IsErrCommentNotExist(err) { |