From f6aa0e3775f547ee70f954ba5a84cbdd4b16c188 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 1 Sep 2018 14:48:54 +0100 Subject: [PATCH 1/6] Fix Swagger JSON. Remove unnecessary schema references for the forbidden and empty responses Signed-off-by: Andrew Thornton --- routers/api/v1/org/member.go | 12 -------- routers/api/v1/org/team.go | 2 -- routers/api/v1/repo/issue.go | 4 --- routers/api/v1/repo/pull.go | 4 --- templates/swagger/v1_json.tmpl | 55 +++++++--------------------------- 5 files changed, 11 insertions(+), 66 deletions(-) diff --git a/routers/api/v1/org/member.go b/routers/api/v1/org/member.go index 65754b88ecd33..b66d86c66032c 100644 --- a/routers/api/v1/org/member.go +++ b/routers/api/v1/org/member.go @@ -117,12 +117,8 @@ func IsMember(ctx *context.APIContext) { // responses: // "204": // description: user is a member - // schema: - // "$ref": "#/responses/empty" // "404": // description: user is not a member - // schema: - // "$ref": "#/responses/empty" userToCheck := user.GetUserByParams(ctx) if ctx.Written() { return @@ -172,12 +168,8 @@ func IsPublicMember(ctx *context.APIContext) { // responses: // "204": // description: user is a public member - // schema: - // "$ref": "#/responses/empty" // "404": // description: user is not a public member - // schema: - // "$ref": "#/responses/empty" userToCheck := user.GetUserByParams(ctx) if ctx.Written() { return @@ -210,8 +202,6 @@ func PublicizeMember(ctx *context.APIContext) { // responses: // "204": // description: membership publicized - // schema: - // "$ref": "#/responses/empty" userToPublicize := user.GetUserByParams(ctx) if ctx.Written() { return @@ -286,8 +276,6 @@ func DeleteMember(ctx *context.APIContext) { // responses: // "204": // description: member removed - // schema: - // "$ref": "#/responses/empty" member := user.GetUserByParams(ctx) if ctx.Written() { return diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index b8dd026bf30e8..d062719678cfa 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -148,8 +148,6 @@ func DeleteTeam(ctx *context.APIContext) { // responses: // "204": // description: team deleted - // schema: - // "$ref": "#/responses/empty" if err := models.DeleteTeam(ctx.Org.Team); err != nil { ctx.Error(500, "DeleteTeam", err) return diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 4b634c9ca602c..93d1274bb09f9 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -387,12 +387,8 @@ func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) { // "$ref": "#/responses/IssueDeadline" // "403": // description: Not repo writer - // schema: - // "$ref": "#/responses/forbidden" // "404": // description: Issue not found - // schema: - // "$ref": "#/responses/empty" issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 0ec2d368711f2..1d3fbb97eb0b2 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -434,12 +434,8 @@ func IsPullRequestMerged(ctx *context.APIContext) { // responses: // "204": // description: pull request has been merged - // schema: - // "$ref": "#/responses/empty" // "404": // description: pull request has not been merged - // schema: - // "$ref": "#/responses/empty" pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrPullRequestNotExist(err) { diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index e6cdfc0270ee3..db89d4e8fb262 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -646,16 +646,10 @@ ], "responses": { "204": { - "description": "user is a member", - "schema": { - "$ref": "#/responses/empty" - } + "description": "user is a member" }, "404": { - "description": "user is not a member", - "schema": { - "$ref": "#/responses/empty" - } + "description": "user is not a member" } } }, @@ -686,10 +680,7 @@ ], "responses": { "204": { - "description": "member removed", - "schema": { - "$ref": "#/responses/empty" - } + "description": "member removed" } } } @@ -745,16 +736,10 @@ ], "responses": { "204": { - "description": "user is a public member", - "schema": { - "$ref": "#/responses/empty" - } + "description": "user is a public member" }, "404": { - "description": "user is not a public member", - "schema": { - "$ref": "#/responses/empty" - } + "description": "user is not a public member" } } }, @@ -785,10 +770,7 @@ ], "responses": { "204": { - "description": "membership publicized", - "schema": { - "$ref": "#/responses/empty" - } + "description": "membership publicized" } } }, @@ -2380,16 +2362,10 @@ "$ref": "#/responses/IssueDeadline" }, "403": { - "description": "Not repo writer", - "schema": { - "$ref": "#/responses/forbidden" - } + "description": "Not repo writer" }, "404": { - "description": "Issue not found", - "schema": { - "$ref": "#/responses/empty" - } + "description": "Issue not found" } } } @@ -3391,16 +3367,10 @@ ], "responses": { "204": { - "description": "pull request has been merged", - "schema": { - "$ref": "#/responses/empty" - } + "description": "pull request has been merged" }, "404": { - "description": "pull request has not been merged", - "schema": { - "$ref": "#/responses/empty" - } + "description": "pull request has not been merged" } } }, @@ -4302,10 +4272,7 @@ ], "responses": { "204": { - "description": "team deleted", - "schema": { - "$ref": "#/responses/empty" - } + "description": "team deleted" } } }, From 28edf7e203a89f25524f5c435fe20318758c2542 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Fri, 19 Oct 2018 18:19:43 +0100 Subject: [PATCH 2/6] Fix swagger API for CreateAccessToken --- routers/api/v1/user/app.go | 9 +++++++++ templates/swagger/v1_json.tmpl | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go index 216190b0f0b93..2f84c4d993691 100644 --- a/routers/api/v1/user/app.go +++ b/routers/api/v1/user/app.go @@ -60,6 +60,15 @@ func CreateAccessToken(ctx *context.APIContext, form api.CreateAccessTokenOption // description: username of user // type: string // required: true + // - name: body + // in: body + // schema: + // type: object + // required: + // - name + // properties: + // name: + // type: string // responses: // "200": // "$ref": "#/responses/AccessToken" diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index db89d4e8fb262..349717ce29816 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -5493,6 +5493,21 @@ "name": "username", "in": "path", "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + } + } + } } ], "responses": { From ea3112cde720472ef203ef19507c6ff0a98bce3b Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 20 Oct 2018 12:04:54 +0100 Subject: [PATCH 3/6] Fix admin create org swagger --- routers/api/v1/admin/org.go | 4 ++++ templates/swagger/v1_json.tmpl | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index d247b51c726e6..406cbb9a31f27 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -28,6 +28,10 @@ func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) { // description: username of the user that will own the created organization // type: string // required: true + // - name: organization + // in: body + // required: true + // schema: { "$ref": "#/definitions/CreateOrgOption" } // responses: // "201": // "$ref": "#/responses/Organization" diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 349717ce29816..03381f3220d9d 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -224,6 +224,14 @@ "name": "username", "in": "path", "required": true + }, + { + "name": "organization", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateOrgOption" + } } ], "responses": { From 77b05bf57271c54b2908dc752b89b9119545df11 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 20 Oct 2018 12:09:12 +0100 Subject: [PATCH 4/6] Fix swagger for adminCreateRepo --- routers/api/v1/admin/repo.go | 4 ++++ templates/swagger/v1_json.tmpl | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/routers/api/v1/admin/repo.go b/routers/api/v1/admin/repo.go index 70765557fb58e..d883e2cbd0eb3 100644 --- a/routers/api/v1/admin/repo.go +++ b/routers/api/v1/admin/repo.go @@ -27,6 +27,10 @@ func CreateRepo(ctx *context.APIContext, form api.CreateRepoOption) { // description: username of the user. This user will own the created repository // type: string // required: true + // - name: repository + // in: body + // required: true + // schema: { "$ref": "#/definitions/CreateRepoOption" } // responses: // "201": // "$ref": "#/responses/Repository" diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 03381f3220d9d..ecadac7609be9 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -267,6 +267,14 @@ "name": "username", "in": "path", "required": true + }, + { + "name": "repository", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateRepoOption" + } } ], "responses": { From fd231f7aae3ce39883ebbdfd5dabab3cb5ccae90 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 20 Oct 2018 12:51:33 +0100 Subject: [PATCH 5/6] More swagger fixes Set int64 format for those which are int64 Some more form fixes --- routers/api/v1/admin/user.go | 5 ++ routers/api/v1/org/hook.go | 12 ++++ routers/api/v1/org/team.go | 8 +++ routers/api/v1/repo/hook.go | 4 ++ routers/api/v1/repo/issue.go | 3 + routers/api/v1/repo/issue_comment.go | 6 ++ routers/api/v1/repo/issue_label.go | 6 ++ routers/api/v1/repo/issue_tracked_time.go | 2 + routers/api/v1/repo/key.go | 2 + routers/api/v1/repo/label.go | 3 + routers/api/v1/repo/milestone.go | 3 + routers/api/v1/repo/pull.go | 4 ++ routers/api/v1/repo/release.go | 3 + routers/api/v1/repo/release_attachment.go | 8 +++ routers/api/v1/repo/repo.go | 2 + routers/api/v1/user/app.go | 3 +- routers/api/v1/user/gpg_key.go | 2 + routers/api/v1/user/key.go | 2 + routers/api/v1/user/user.go | 1 + templates/swagger/v1_json.tmpl | 88 ++++++++++++++++++++++- 20 files changed, 165 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 958c083fb6f9e..cff8ae4850f0b 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -228,6 +228,10 @@ func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) { // description: username of the user // type: string // required: true + // - name: key + // in: body + // schema: + // "$ref": "#/definitions/CreateKeyOption" // responses: // "201": // "$ref": "#/responses/PublicKey" @@ -259,6 +263,7 @@ func DeleteUserPublicKey(ctx *context.APIContext) { // in: path // description: id of the key to delete // type: integer + // format: int64 // required: true // responses: // "204": diff --git a/routers/api/v1/org/hook.go b/routers/api/v1/org/hook.go index 83d2a5e5ba075..84559a958e3c1 100644 --- a/routers/api/v1/org/hook.go +++ b/routers/api/v1/org/hook.go @@ -59,6 +59,7 @@ func GetHook(ctx *context.APIContext) { // in: path // description: id of the hook to get // type: integer + // format: int64 // required: true // responses: // "200": @@ -87,6 +88,11 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { // description: name of the organization // type: string // required: true + // - name: body + // in: body + // required: true + // schema: + // "$ref": "#/definitions/CreateHookOption" // responses: // "201": // "$ref": "#/responses/Hook" @@ -117,7 +123,12 @@ func EditHook(ctx *context.APIContext, form api.EditHookOption) { // in: path // description: id of the hook to update // type: integer + // format: int64 // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/EditHookOption" // responses: // "200": // "$ref": "#/responses/Hook" @@ -144,6 +155,7 @@ func DeleteHook(ctx *context.APIContext) { // in: path // description: id of the hook to delete // type: integer + // format: int64 // required: true // responses: // "204": diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index d062719678cfa..2e319a18310ce 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -54,6 +54,7 @@ func GetTeam(ctx *context.APIContext) { // in: path // description: id of the team to get // type: integer + // format: int64 // required: true // responses: // "200": @@ -144,6 +145,7 @@ func DeleteTeam(ctx *context.APIContext) { // in: path // description: id of the team to delete // type: integer + // format: int64 // required: true // responses: // "204": @@ -167,6 +169,7 @@ func GetTeamMembers(ctx *context.APIContext) { // in: path // description: id of the team // type: integer + // format: int64 // required: true // responses: // "200": @@ -203,6 +206,7 @@ func AddTeamMember(ctx *context.APIContext) { // in: path // description: id of the team // type: integer + // format: int64 // required: true // - name: username // in: path @@ -235,6 +239,7 @@ func RemoveTeamMember(ctx *context.APIContext) { // in: path // description: id of the team // type: integer + // format: int64 // required: true // - name: username // in: path @@ -268,6 +273,7 @@ func GetTeamRepos(ctx *context.APIContext) { // in: path // description: id of the team // type: integer + // format: int64 // required: true // responses: // "200": @@ -314,6 +320,7 @@ func AddTeamRepository(ctx *context.APIContext) { // in: path // description: id of the team // type: integer + // format: int64 // required: true // - name: org // in: path @@ -360,6 +367,7 @@ func RemoveTeamRepository(ctx *context.APIContext) { // in: path // description: id of the team // type: integer + // format: int64 // required: true // - name: org // in: path diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go index 1f121dfc387b1..369603694fd42 100644 --- a/routers/api/v1/repo/hook.go +++ b/routers/api/v1/repo/hook.go @@ -69,6 +69,7 @@ func GetHook(ctx *context.APIContext) { // in: path // description: id of the hook to get // type: integer + // format: int64 // required: true // responses: // "200": @@ -104,6 +105,7 @@ func TestHook(ctx *context.APIContext) { // in: path // description: id of the hook to test // type: integer + // format: int64 // required: true // responses: // "204": @@ -193,6 +195,7 @@ func EditHook(ctx *context.APIContext, form api.EditHookOption) { // in: path // description: index of the hook // type: integer + // format: int64 // required: true // - name: body // in: body @@ -227,6 +230,7 @@ func DeleteHook(ctx *context.APIContext) { // in: path // description: id of the hook to delete // type: integer + // format: int64 // required: true // responses: // "204": diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 93d1274bb09f9..cd78135a62160 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -123,6 +123,7 @@ func GetIssue(ctx *context.APIContext) { // in: path // description: index of the issue to get // type: integer + // format: int64 // required: true // responses: // "200": @@ -254,6 +255,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { // in: path // description: index of the issue to edit // type: integer + // format: int64 // required: true // - name: body // in: body @@ -377,6 +379,7 @@ func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) { // in: path // description: index of the issue to create or update a deadline on // type: integer + // format: int64 // required: true // - name: body // in: body diff --git a/routers/api/v1/repo/issue_comment.go b/routers/api/v1/repo/issue_comment.go index f958922914f7a..3af0290585f9e 100644 --- a/routers/api/v1/repo/issue_comment.go +++ b/routers/api/v1/repo/issue_comment.go @@ -36,6 +36,7 @@ func ListIssueComments(ctx *context.APIContext) { // in: path // description: index of the issue // type: integer + // format: int64 // required: true // - name: since // in: query @@ -144,6 +145,7 @@ func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOpti // in: path // description: index of the issue // type: integer + // format: int64 // required: true // - name: body // in: body @@ -193,6 +195,7 @@ func EditIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) // in: path // description: id of the comment to edit // type: integer + // format: int64 // required: true // - name: body // in: body @@ -234,6 +237,7 @@ func EditIssueCommentDeprecated(ctx *context.APIContext, form api.EditIssueComme // in: path // description: id of the comment to edit // type: integer + // format: int64 // required: true // - name: body // in: body @@ -293,6 +297,7 @@ func DeleteIssueComment(ctx *context.APIContext) { // in: path // description: id of comment to delete // type: integer + // format: int64 // required: true // responses: // "204": @@ -326,6 +331,7 @@ func DeleteIssueCommentDeprecated(ctx *context.APIContext) { // in: path // description: id of comment to delete // type: integer + // format: int64 // required: true // responses: // "204": diff --git a/routers/api/v1/repo/issue_label.go b/routers/api/v1/repo/issue_label.go index 3657f02c65299..35defa25b57d1 100644 --- a/routers/api/v1/repo/issue_label.go +++ b/routers/api/v1/repo/issue_label.go @@ -33,6 +33,7 @@ func ListIssueLabels(ctx *context.APIContext) { // in: path // description: index of the issue // type: integer + // format: int64 // required: true // responses: // "200": @@ -80,6 +81,7 @@ func AddIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) { // in: path // description: index of the issue // type: integer + // format: int64 // required: true // - name: body // in: body @@ -149,11 +151,13 @@ func DeleteIssueLabel(ctx *context.APIContext) { // in: path // description: index of the issue // type: integer + // format: int64 // required: true // - name: id // in: path // description: id of the label to remove // type: integer + // format: int64 // required: true // responses: // "204": @@ -215,6 +219,7 @@ func ReplaceIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) { // in: path // description: index of the issue // type: integer + // format: int64 // required: true // - name: body // in: body @@ -284,6 +289,7 @@ func ClearIssueLabels(ctx *context.APIContext) { // in: path // description: index of the issue // type: integer + // format: int64 // required: true // responses: // "204": diff --git a/routers/api/v1/repo/issue_tracked_time.go b/routers/api/v1/repo/issue_tracked_time.go index 9be9fee91a424..6c29b11b4bb07 100644 --- a/routers/api/v1/repo/issue_tracked_time.go +++ b/routers/api/v1/repo/issue_tracked_time.go @@ -41,6 +41,7 @@ func ListTrackedTimes(ctx *context.APIContext) { // in: path // description: index of the issue // type: integer + // format: int64 // required: true // responses: // "200": @@ -92,6 +93,7 @@ func AddTime(ctx *context.APIContext, form api.AddTimeOption) { // in: path // description: index of the issue to add tracked time to // type: integer + // format: int64 // required: true // - name: body // in: body diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go index 1e3666ed42d75..89a550cfd318f 100644 --- a/routers/api/v1/repo/key.go +++ b/routers/api/v1/repo/key.go @@ -81,6 +81,7 @@ func GetDeployKey(ctx *context.APIContext) { // in: path // description: id of the key to get // type: integer + // format: int64 // required: true // responses: // "200": @@ -191,6 +192,7 @@ func DeleteDeploykey(ctx *context.APIContext) { // in: path // description: id of the key to delete // type: integer + // format: int64 // required: true // responses: // "204": diff --git a/routers/api/v1/repo/label.go b/routers/api/v1/repo/label.go index 77392787ef5ef..359ccf0e41eca 100644 --- a/routers/api/v1/repo/label.go +++ b/routers/api/v1/repo/label.go @@ -69,6 +69,7 @@ func GetLabel(ctx *context.APIContext) { // in: path // description: id of the label to get // type: integer + // format: int64 // required: true // responses: // "200": @@ -163,6 +164,7 @@ func EditLabel(ctx *context.APIContext, form api.EditLabelOption) { // in: path // description: id of the label to edit // type: integer + // format: int64 // required: true // - name: body // in: body @@ -219,6 +221,7 @@ func DeleteLabel(ctx *context.APIContext) { // in: path // description: id of the label to delete // type: integer + // format: int64 // required: true // responses: // "204": diff --git a/routers/api/v1/repo/milestone.go b/routers/api/v1/repo/milestone.go index a138cb7a69a0c..c621536ad720c 100644 --- a/routers/api/v1/repo/milestone.go +++ b/routers/api/v1/repo/milestone.go @@ -70,6 +70,7 @@ func GetMilestone(ctx *context.APIContext) { // in: path // description: id of the milestone // type: integer + // format: int64 // required: true // responses: // "200": @@ -156,6 +157,7 @@ func EditMilestone(ctx *context.APIContext, form api.EditMilestoneOption) { // in: path // description: id of the milestone // type: integer + // format: int64 // required: true // - name: body // in: body @@ -211,6 +213,7 @@ func DeleteMilestone(ctx *context.APIContext) { // in: path // description: id of the milestone to delete // type: integer + // format: int64 // required: true // responses: // "204": diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 1d3fbb97eb0b2..07e7a1d6cb9fe 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -101,6 +101,7 @@ func GetPullRequest(ctx *context.APIContext) { // in: path // description: index of the pull request to get // type: integer + // format: int64 // required: true // responses: // "200": @@ -301,6 +302,7 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) { // in: path // description: index of the pull request to edit // type: integer + // format: int64 // required: true // - name: body // in: body @@ -430,6 +432,7 @@ func IsPullRequestMerged(ctx *context.APIContext) { // in: path // description: index of the pull request // type: integer + // format: int64 // required: true // responses: // "204": @@ -474,6 +477,7 @@ func MergePullRequest(ctx *context.APIContext, form auth.MergePullRequestForm) { // in: path // description: index of the pull request to merge // type: integer + // format: int64 // required: true // responses: // "200": diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go index 7c3de3581b11b..282ff582c509f 100644 --- a/routers/api/v1/repo/release.go +++ b/routers/api/v1/repo/release.go @@ -33,6 +33,7 @@ func GetRelease(ctx *context.APIContext) { // in: path // description: id of the release to get // type: integer + // format: int64 // required: true // responses: // "200": @@ -199,6 +200,7 @@ func EditRelease(ctx *context.APIContext, form api.EditReleaseOption) { // in: path // description: id of the release to edit // type: integer + // format: int64 // required: true // - name: body // in: body @@ -278,6 +280,7 @@ func DeleteRelease(ctx *context.APIContext) { // in: path // description: id of the release to delete // type: integer + // format: int64 // required: true // responses: // "204": diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go index f11fac16294e5..ea2be719f377e 100644 --- a/routers/api/v1/repo/release_attachment.go +++ b/routers/api/v1/repo/release_attachment.go @@ -38,11 +38,13 @@ func GetReleaseAttachment(ctx *context.APIContext) { // in: path // description: id of the release // type: integer + // format: int64 // required: true // - name: attachment_id // in: path // description: id of the attachment to get // type: integer + // format: int64 // required: true // responses: // "200": @@ -84,6 +86,7 @@ func ListReleaseAttachments(ctx *context.APIContext) { // in: path // description: id of the release // type: integer + // format: int64 // required: true // responses: // "200": @@ -129,6 +132,7 @@ func CreateReleaseAttachment(ctx *context.APIContext) { // in: path // description: id of the release // type: integer + // format: int64 // required: true // - name: name // in: query @@ -233,11 +237,13 @@ func EditReleaseAttachment(ctx *context.APIContext, form api.EditAttachmentOptio // in: path // description: id of the release // type: integer + // format: int64 // required: true // - name: attachment_id // in: path // description: id of the attachment to edit // type: integer + // format: int64 // required: true // - name: body // in: body @@ -292,11 +298,13 @@ func DeleteReleaseAttachment(ctx *context.APIContext) { // in: path // description: id of the release // type: integer + // format: int64 // required: true // - name: attachment_id // in: path // description: id of the attachment to delete // type: integer + // format: int64 // required: true // responses: // "204": diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index e48b100af61cb..bf6346eebdfca 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -53,6 +53,7 @@ func Search(ctx *context.APIContext) { // in: query // description: search only for repos that the user with the given id owns or contributes to // type: integer + // format: int64 // - name: page // in: query // description: page number of results to return (1-based) @@ -453,6 +454,7 @@ func GetByID(ctx *context.APIContext) { // in: path // description: id of the repo to get // type: integer + // format: int64 // required: true // responses: // "200": diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go index 2f84c4d993691..f4870431c202f 100644 --- a/routers/api/v1/user/app.go +++ b/routers/api/v1/user/app.go @@ -60,7 +60,7 @@ func CreateAccessToken(ctx *context.APIContext, form api.CreateAccessTokenOption // description: username of user // type: string // required: true - // - name: body + // - name: accessToken // in: body // schema: // type: object @@ -104,6 +104,7 @@ func DeleteAccessToken(ctx *context.APIContext) { // in: path // description: token to be deleted // type: integer + // format: int64 // required: true // responses: // "204": diff --git a/routers/api/v1/user/gpg_key.go b/routers/api/v1/user/gpg_key.go index a955f3ff1480c..5301a0f2dbbcd 100644 --- a/routers/api/v1/user/gpg_key.go +++ b/routers/api/v1/user/gpg_key.go @@ -80,6 +80,7 @@ func GetGPGKey(ctx *context.APIContext) { // in: path // description: id of key to get // type: integer + // format: int64 // required: true // responses: // "200": @@ -143,6 +144,7 @@ func DeleteGPGKey(ctx *context.APIContext) { // in: path // description: id of key to delete // type: integer + // format: int64 // required: true // responses: // "204": diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go index 41a514af5e458..e5d1b08f0dab5 100644 --- a/routers/api/v1/user/key.go +++ b/routers/api/v1/user/key.go @@ -101,6 +101,7 @@ func GetPublicKey(ctx *context.APIContext) { // in: path // description: id of key to get // type: integer + // format: int64 // required: true // responses: // "200": @@ -172,6 +173,7 @@ func DeletePublicKey(ctx *context.APIContext) { // in: path // description: id of key to delete // type: integer + // format: int64 // required: true // responses: // "204": diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index 38576a7337df2..51d69aa2c32cf 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -31,6 +31,7 @@ func Search(ctx *context.APIContext) { // in: query // description: ID of the user to search for // type: integer + // format: int64 // - name: limit // in: query // description: maximum number of users to return diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index ecadac7609be9..0a2ebf86913ae 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -150,6 +150,13 @@ "name": "username", "in": "path", "required": true + }, + { + "name": "key", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateKeyOption" + } } ], "responses": { @@ -185,6 +192,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the key to delete", "name": "id", "in": "path", @@ -504,6 +512,14 @@ "name": "org", "in": "path", "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateHookOption" + } } ], "responses": { @@ -533,6 +549,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the hook to get", "name": "id", "in": "path", @@ -564,6 +581,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the hook to delete", "name": "id", "in": "path", @@ -598,10 +616,18 @@ }, { "type": "integer", + "format": "int64", "description": "id of the hook to update", "name": "id", "in": "path", "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditHookOption" + } } ], "responses": { @@ -956,6 +982,7 @@ }, { "type": "integer", + "format": "int64", "description": "search only for repos that the user with the given id owns or contributes to", "name": "uid", "in": "query" @@ -1598,6 +1625,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the hook to get", "name": "id", "in": "path", @@ -1636,6 +1664,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the hook to delete", "name": "id", "in": "path", @@ -1677,6 +1706,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the hook", "name": "id", "in": "path", @@ -1724,6 +1754,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the hook to test", "name": "id", "in": "path", @@ -1892,6 +1923,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of comment to delete", "name": "id", "in": "path", @@ -1933,6 +1965,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the comment to edit", "name": "id", "in": "path", @@ -1980,6 +2013,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the issue", "name": "id", "in": "path", @@ -2021,6 +2055,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the issue to add tracked time to", "name": "id", "in": "path", @@ -2074,6 +2109,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the issue to get", "name": "index", "in": "path", @@ -2115,6 +2151,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the issue to edit", "name": "index", "in": "path", @@ -2162,6 +2199,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the issue", "name": "index", "in": "path", @@ -2209,6 +2247,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the issue", "name": "index", "in": "path", @@ -2261,6 +2300,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of comment to delete", "name": "id", "in": "path", @@ -2310,6 +2350,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the comment to edit", "name": "id", "in": "path", @@ -2360,6 +2401,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the issue to create or update a deadline on", "name": "index", "in": "path", @@ -2413,6 +2455,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the issue", "name": "index", "in": "path", @@ -2457,6 +2500,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the issue", "name": "index", "in": "path", @@ -2505,6 +2549,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the issue", "name": "index", "in": "path", @@ -2550,6 +2595,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the issue", "name": "index", "in": "path", @@ -2590,6 +2636,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the issue", "name": "index", "in": "path", @@ -2597,6 +2644,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the label to remove", "name": "id", "in": "path", @@ -2711,6 +2759,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the key to get", "name": "id", "in": "path", @@ -2746,6 +2795,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the key to delete", "name": "id", "in": "path", @@ -2860,6 +2910,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the label to get", "name": "id", "in": "path", @@ -2895,6 +2946,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the label to delete", "name": "id", "in": "path", @@ -2936,6 +2988,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the label to edit", "name": "id", "in": "path", @@ -3057,6 +3110,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the milestone", "name": "id", "in": "path", @@ -3092,6 +3146,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the milestone to delete", "name": "id", "in": "path", @@ -3133,6 +3188,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the milestone", "name": "id", "in": "path", @@ -3287,6 +3343,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the pull request to get", "name": "index", "in": "path", @@ -3328,6 +3385,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the pull request to edit", "name": "index", "in": "path", @@ -3375,6 +3433,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the pull request", "name": "index", "in": "path", @@ -3416,6 +3475,7 @@ }, { "type": "integer", + "format": "int64", "description": "index of the pull request to merge", "name": "index", "in": "path", @@ -3573,6 +3633,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the release to get", "name": "id", "in": "path", @@ -3608,6 +3669,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the release to delete", "name": "id", "in": "path", @@ -3649,6 +3711,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the release to edit", "name": "id", "in": "path", @@ -3696,6 +3759,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the release", "name": "id", "in": "path", @@ -3737,6 +3801,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the release", "name": "id", "in": "path", @@ -3790,6 +3855,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the release", "name": "id", "in": "path", @@ -3797,6 +3863,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the attachment to get", "name": "attachment_id", "in": "path", @@ -3835,6 +3902,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the release", "name": "id", "in": "path", @@ -3842,6 +3910,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the attachment to delete", "name": "attachment_id", "in": "path", @@ -3883,6 +3952,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the release", "name": "id", "in": "path", @@ -3890,6 +3960,7 @@ }, { "type": "integer", + "format": "int64", "description": "id of the attachment to edit", "name": "attachment_id", "in": "path", @@ -4233,6 +4304,7 @@ "parameters": [ { "type": "integer", + "format": "int64", "description": "id of the repo to get", "name": "id", "in": "path", @@ -4259,6 +4331,7 @@ "parameters": [ { "type": "integer", + "format": "int64", "description": "id of the team to get", "name": "id", "in": "path", @@ -4280,6 +4353,7 @@ "parameters": [ { "type": "integer", + "format": "int64", "description": "id of the team to delete", "name": "id", "in": "path", @@ -4340,6 +4414,7 @@ "parameters": [ { "type": "integer", + "format": "int64", "description": "id of the team", "name": "id", "in": "path", @@ -4366,6 +4441,7 @@ "parameters": [ { "type": "integer", + "format": "int64", "description": "id of the team", "name": "id", "in": "path", @@ -4397,6 +4473,7 @@ "parameters": [ { "type": "integer", + "format": "int64", "description": "id of the team", "name": "id", "in": "path", @@ -4430,6 +4507,7 @@ "parameters": [ { "type": "integer", + "format": "int64", "description": "id of the team", "name": "id", "in": "path", @@ -4456,6 +4534,7 @@ "parameters": [ { "type": "integer", + "format": "int64", "description": "id of the team", "name": "id", "in": "path", @@ -4495,6 +4574,7 @@ "parameters": [ { "type": "integer", + "format": "int64", "description": "id of the team", "name": "id", "in": "path", @@ -4792,6 +4872,7 @@ "parameters": [ { "type": "integer", + "format": "int64", "description": "id of key to get", "name": "id", "in": "path", @@ -4819,6 +4900,7 @@ "parameters": [ { "type": "integer", + "format": "int64", "description": "id of key to delete", "name": "id", "in": "path", @@ -4895,6 +4977,7 @@ "parameters": [ { "type": "integer", + "format": "int64", "description": "id of key to get", "name": "id", "in": "path", @@ -4922,6 +5005,7 @@ "parameters": [ { "type": "integer", + "format": "int64", "description": "id of key to delete", "name": "id", "in": "path", @@ -5188,6 +5272,7 @@ }, { "type": "integer", + "format": "int64", "description": "ID of the user to search for", "name": "uid", "in": "query" @@ -5511,7 +5596,7 @@ "required": true }, { - "name": "body", + "name": "accessToken", "in": "body", "schema": { "type": "object", @@ -5553,6 +5638,7 @@ }, { "type": "integer", + "format": "int64", "description": "token to be deleted", "name": "token", "in": "path", From d7e86e6b02702cfe52051ecf45c7aef87cefd71b Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 20 Oct 2018 13:42:36 +0100 Subject: [PATCH 6/6] Fix swagger description of GET /repos/{owner}/{repo}/pulls --- routers/api/v1/repo/pull.go | 27 +++++++++++++++++++ templates/swagger/v1_json.tmpl | 49 ++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 07e7a1d6cb9fe..5ce6f868bcd09 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -38,6 +38,33 @@ func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions) // description: name of the repo // type: string // required: true + // - name: page + // in: query + // description: Page number + // type: integer + // - name: state + // in: query + // description: "State of pull request: open or closed (optional)" + // type: string + // enum: [closed, open, all] + // - name: sort + // in: query + // description: "Type of sort" + // type: string + // enum: [oldest, recentupdate, leastupdate, mostcomment, leastcomment, priority] + // - name: milestone + // in: query + // description: "ID of the milestone" + // type: integer + // format: int64 + // - name: labels + // in: query + // description: "Label IDs" + // type: array + // collectionFormat: multi + // items: + // type: integer + // format: int64 // responses: // "200": // "$ref": "#/responses/PullRequestList" diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 0a2ebf86913ae..193579f6bed73 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -3266,6 +3266,55 @@ "name": "repo", "in": "path", "required": true + }, + { + "type": "integer", + "description": "Page number", + "name": "page", + "in": "query" + }, + { + "enum": [ + "closed", + "open", + "all" + ], + "type": "string", + "description": "State of pull request: open or closed (optional)", + "name": "state", + "in": "query" + }, + { + "enum": [ + "oldest", + "recentupdate", + "leastupdate", + "mostcomment", + "leastcomment", + "priority" + ], + "type": "string", + "description": "Type of sort", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "ID of the milestone", + "name": "milestone", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + }, + "collectionFormat": "multi", + "description": "Label IDs", + "name": "labels", + "in": "query" } ], "responses": {