Skip to content

Commit c3b6383

Browse files
ethantkoeniglunny
authored andcommitted
Fix comment API paths (#2813)
1 parent 876bafb commit c3b6383

File tree

4 files changed

+278
-94
lines changed

4 files changed

+278
-94
lines changed

integrations/api_comment_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ func TestAPIEditComment(t *testing.T) {
9393
repoOwner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
9494

9595
session := loginUser(t, repoOwner.Name)
96-
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/comments/%d",
97-
repoOwner.Name, repo.Name, issue.Index, comment.ID)
96+
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments/%d",
97+
repoOwner.Name, repo.Name, comment.ID)
9898
req := NewRequestWithValues(t, "PATCH", urlStr, map[string]string{
9999
"body": newCommentBody,
100100
})
@@ -117,8 +117,8 @@ func TestAPIDeleteComment(t *testing.T) {
117117
repoOwner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
118118

119119
session := loginUser(t, repoOwner.Name)
120-
req := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/issues/%d/comments/%d",
121-
repoOwner.Name, repo.Name, issue.Index, comment.ID)
120+
req := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/issues/comments/%d",
121+
repoOwner.Name, repo.Name, comment.ID)
122122
session.MakeRequest(t, req, http.StatusNoContent)
123123

124124
models.AssertNotExistsBean(t, &models.Comment{ID: comment.ID})

public/swagger.v1.json

Lines changed: 186 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,91 +1225,6 @@
12251225
}
12261226
}
12271227
},
1228-
"/repos/{owner}/{repo}/comments/{id}": {
1229-
"delete": {
1230-
"tags": [
1231-
"issue"
1232-
],
1233-
"summary": "Delete a comment",
1234-
"operationId": "issueDeleteComment",
1235-
"parameters": [
1236-
{
1237-
"type": "string",
1238-
"description": "owner of the repo",
1239-
"name": "owner",
1240-
"in": "path",
1241-
"required": true
1242-
},
1243-
{
1244-
"type": "string",
1245-
"description": "name of the repo",
1246-
"name": "repo",
1247-
"in": "path",
1248-
"required": true
1249-
},
1250-
{
1251-
"type": "integer",
1252-
"description": "id of comment to delete",
1253-
"name": "id",
1254-
"in": "path",
1255-
"required": true
1256-
}
1257-
],
1258-
"responses": {
1259-
"204": {
1260-
"$ref": "#/responses/empty"
1261-
}
1262-
}
1263-
},
1264-
"patch": {
1265-
"consumes": [
1266-
"application/json"
1267-
],
1268-
"produces": [
1269-
"application/json"
1270-
],
1271-
"tags": [
1272-
"issue"
1273-
],
1274-
"summary": "Edit a comment",
1275-
"operationId": "issueEditComment",
1276-
"parameters": [
1277-
{
1278-
"type": "string",
1279-
"description": "owner of the repo",
1280-
"name": "owner",
1281-
"in": "path",
1282-
"required": true
1283-
},
1284-
{
1285-
"type": "string",
1286-
"description": "name of the repo",
1287-
"name": "repo",
1288-
"in": "path",
1289-
"required": true
1290-
},
1291-
{
1292-
"type": "integer",
1293-
"description": "id of the comment to edit",
1294-
"name": "id",
1295-
"in": "path",
1296-
"required": true
1297-
},
1298-
{
1299-
"name": "body",
1300-
"in": "body",
1301-
"schema": {
1302-
"$ref": "#/definitions/EditIssueCommentOption"
1303-
}
1304-
}
1305-
],
1306-
"responses": {
1307-
"200": {
1308-
"$ref": "#/responses/Comment"
1309-
}
1310-
}
1311-
}
1312-
},
13131228
"/repos/{owner}/{repo}/commits/{ref}/statuses": {
13141229
"get": {
13151230
"produces": [
@@ -1965,6 +1880,91 @@
19651880
}
19661881
}
19671882
},
1883+
"/repos/{owner}/{repo}/issues/comments/{id}": {
1884+
"delete": {
1885+
"tags": [
1886+
"issue"
1887+
],
1888+
"summary": "Delete a comment",
1889+
"operationId": "issueDeleteComment",
1890+
"parameters": [
1891+
{
1892+
"type": "string",
1893+
"description": "owner of the repo",
1894+
"name": "owner",
1895+
"in": "path",
1896+
"required": true
1897+
},
1898+
{
1899+
"type": "string",
1900+
"description": "name of the repo",
1901+
"name": "repo",
1902+
"in": "path",
1903+
"required": true
1904+
},
1905+
{
1906+
"type": "integer",
1907+
"description": "id of comment to delete",
1908+
"name": "id",
1909+
"in": "path",
1910+
"required": true
1911+
}
1912+
],
1913+
"responses": {
1914+
"204": {
1915+
"$ref": "#/responses/empty"
1916+
}
1917+
}
1918+
},
1919+
"patch": {
1920+
"consumes": [
1921+
"application/json"
1922+
],
1923+
"produces": [
1924+
"application/json"
1925+
],
1926+
"tags": [
1927+
"issue"
1928+
],
1929+
"summary": "Edit a comment",
1930+
"operationId": "issueEditComment",
1931+
"parameters": [
1932+
{
1933+
"type": "string",
1934+
"description": "owner of the repo",
1935+
"name": "owner",
1936+
"in": "path",
1937+
"required": true
1938+
},
1939+
{
1940+
"type": "string",
1941+
"description": "name of the repo",
1942+
"name": "repo",
1943+
"in": "path",
1944+
"required": true
1945+
},
1946+
{
1947+
"type": "integer",
1948+
"description": "id of the comment to edit",
1949+
"name": "id",
1950+
"in": "path",
1951+
"required": true
1952+
},
1953+
{
1954+
"name": "body",
1955+
"in": "body",
1956+
"schema": {
1957+
"$ref": "#/definitions/EditIssueCommentOption"
1958+
}
1959+
}
1960+
],
1961+
"responses": {
1962+
"200": {
1963+
"$ref": "#/responses/Comment"
1964+
}
1965+
}
1966+
}
1967+
},
19681968
"/repos/{owner}/{repo}/issues/{id}": {
19691969
"get": {
19701970
"produces": [
@@ -2103,6 +2103,107 @@
21032103
}
21042104
}
21052105
},
2106+
"/repos/{owner}/{repo}/issues/{index}/comments/{id}": {
2107+
"delete": {
2108+
"tags": [
2109+
"issue"
2110+
],
2111+
"summary": "Delete a comment",
2112+
"operationId": "issueDeleteCommentDeprecated",
2113+
"deprecated": true,
2114+
"parameters": [
2115+
{
2116+
"type": "string",
2117+
"description": "owner of the repo",
2118+
"name": "owner",
2119+
"in": "path",
2120+
"required": true
2121+
},
2122+
{
2123+
"type": "string",
2124+
"description": "name of the repo",
2125+
"name": "repo",
2126+
"in": "path",
2127+
"required": true
2128+
},
2129+
{
2130+
"type": "integer",
2131+
"description": "this parameter is ignored",
2132+
"name": "index",
2133+
"in": "path",
2134+
"required": true
2135+
},
2136+
{
2137+
"type": "integer",
2138+
"description": "id of comment to delete",
2139+
"name": "id",
2140+
"in": "path",
2141+
"required": true
2142+
}
2143+
],
2144+
"responses": {
2145+
"204": {
2146+
"$ref": "#/responses/empty"
2147+
}
2148+
}
2149+
},
2150+
"patch": {
2151+
"consumes": [
2152+
"application/json"
2153+
],
2154+
"produces": [
2155+
"application/json"
2156+
],
2157+
"tags": [
2158+
"issue"
2159+
],
2160+
"summary": "Edit a comment",
2161+
"operationId": "issueEditCommentDeprecated",
2162+
"deprecated": true,
2163+
"parameters": [
2164+
{
2165+
"type": "string",
2166+
"description": "owner of the repo",
2167+
"name": "owner",
2168+
"in": "path",
2169+
"required": true
2170+
},
2171+
{
2172+
"type": "string",
2173+
"description": "name of the repo",
2174+
"name": "repo",
2175+
"in": "path",
2176+
"required": true
2177+
},
2178+
{
2179+
"type": "integer",
2180+
"description": "this parameter is ignored",
2181+
"name": "index",
2182+
"in": "path",
2183+
"required": true
2184+
},
2185+
{
2186+
"type": "integer",
2187+
"description": "id of the comment to edit",
2188+
"name": "id",
2189+
"in": "path",
2190+
"required": true
2191+
},
2192+
{
2193+
"name": "body",
2194+
"in": "body",
2195+
"schema": {
2196+
"$ref": "#/definitions/EditIssueCommentOption"
2197+
}
2198+
}
2199+
],
2200+
"responses": {
2201+
"200": {
2202+
"$ref": "#/responses/Comment"
2203+
}
2204+
}
2205+
}
2206+
},
21062207
"/repos/{owner}/{repo}/issues/{index}/labels": {
21072208
"get": {
21082209
"produces": [

routers/api/v1/api.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ func RegisterRoutes(m *macaron.Macaron) {
406406
m.Group("/comments", func() {
407407
m.Get("", repo.ListRepoIssueComments)
408408
m.Combo("/:id", reqToken()).
409-
Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueComment)
409+
Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueComment).
410+
Delete(repo.DeleteIssueComment)
410411
})
411412
m.Group("/:index", func() {
412413
m.Combo("").Get(repo.GetIssue).
@@ -415,8 +416,8 @@ func RegisterRoutes(m *macaron.Macaron) {
415416
m.Group("/comments", func() {
416417
m.Combo("").Get(repo.ListIssueComments).
417418
Post(reqToken(), bind(api.CreateIssueCommentOption{}), repo.CreateIssueComment)
418-
m.Combo("/:id", reqToken()).Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueComment).
419-
Delete(repo.DeleteIssueComment)
419+
m.Combo("/:id", reqToken()).Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueCommentDeprecated).
420+
Delete(repo.DeleteIssueCommentDeprecated)
420421
})
421422

422423
m.Group("/labels", func() {

0 commit comments

Comments
 (0)