Skip to content

Commit

Permalink
Fix comment API paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ethantkoenig committed Nov 19, 2017
1 parent 061f65f commit 96d1009
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 94 deletions.
8 changes: 4 additions & 4 deletions integrations/api_comment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func TestAPIEditComment(t *testing.T) {
repoOwner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)

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{
"body": newCommentBody,
})
Expand All @@ -117,8 +117,8 @@ func TestAPIDeleteComment(t *testing.T) {
repoOwner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)

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)

models.AssertNotExistsBean(t, &models.Comment{ID: comment.ID})
Expand Down
271 changes: 186 additions & 85 deletions public/swagger.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -1225,91 +1225,6 @@
}
}
},
"/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": {
"get": {
"produces": [
Expand Down Expand Up @@ -1965,6 +1880,91 @@
}
}
},
"/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}": {
"get": {
"produces": [
Expand Down Expand Up @@ -2103,6 +2103,107 @@
}
}
},
"/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": {
"get": {
"produces": [
Expand Down
7 changes: 4 additions & 3 deletions routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/comments", func() {
m.Get("", repo.ListRepoIssueComments)
m.Combo("/:id", reqToken()).
Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueComment)
Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueComment).
Delete(repo.DeleteIssueComment)
})
m.Group("/:index", func() {
m.Combo("").Get(repo.GetIssue).
Expand All @@ -415,8 +416,8 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/comments", func() {
m.Combo("").Get(repo.ListIssueComments).
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() {
Expand Down

0 comments on commit 96d1009

Please sign in to comment.