1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Fix swagger errors (#4220)

Fix all the resting errors to have a valid swagger file.

They are still some warnings but nothing blocking.

Doing so I found that some request still misses son parameters for some POST/PUT/PATCH request. This means the a client generated from the swagger file will not work completely. 

Fix #4088 by activating validation in drone
Should fix #4010.
This commit is contained in:
Antoine GIRARD
2018-06-12 16:59:22 +02:00
committed by Bo-Yi Wu
parent 0ba165e2ea
commit 908e8942cc
15 changed files with 440 additions and 262 deletions

View File

@@ -16,30 +16,7 @@ import (
// ListMilestones list all the milestones for a repository
func ListMilestones(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/milestones/{id} issue issueGetMilestone
// ---
// summary: Get a milestone
// produces:
// - application/json
// responses:
// "200":
// "$ref": "#/responses/Milestone"
milestones, err := models.GetMilestonesByRepoID(ctx.Repo.Repository.ID)
if err != nil {
ctx.Error(500, "GetMilestonesByRepoID", err)
return
}
apiMilestones := make([]*api.Milestone, len(milestones))
for i := range milestones {
apiMilestones[i] = milestones[i].APIFormat()
}
ctx.JSON(200, &apiMilestones)
}
// GetMilestone get a milestone for a repository
func GetMilestone(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/milestones issue issueGetMilestones
// swagger:operation GET /repos/{owner}/{repo}/milestones issue issueGetMilestonesList
// ---
// summary: Get all of a repository's milestones
// produces:
@@ -55,6 +32,29 @@ func GetMilestone(ctx *context.APIContext) {
// description: name of the repo
// type: string
// required: true
// responses:
// "200":
// "$ref": "#/responses/MilestoneList"
milestones, err := models.GetMilestonesByRepoID(ctx.Repo.Repository.ID)
if err != nil {
ctx.Error(500, "GetMilestonesByRepoID", err)
return
}
apiMilestones := make([]*api.Milestone, len(milestones))
for i := range milestones {
apiMilestones[i] = milestones[i].APIFormat()
}
ctx.JSON(200, &apiMilestones)
}
// GetMilestone get a milestone for a repository
func GetMilestone(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/milestones/{id} issue issueGetMilestone
// ---
// summary: Get a milestone
// produces:
// - application/json
// parameters:
// - name: owner
// in: path
@@ -68,12 +68,12 @@ func GetMilestone(ctx *context.APIContext) {
// required: true
// - name: id
// in: path
// description: id of the milestone to get
// description: id of the milestone
// type: integer
// required: true
// responses:
// "200":
// "$ref": "#/responses/MilestoneList"
// "$ref": "#/responses/Milestone"
milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
if err != nil {
if models.IsErrMilestoneNotExist(err) {
@@ -152,6 +152,11 @@ func EditMilestone(ctx *context.APIContext, form api.EditMilestoneOption) {
// description: name of the repo
// type: string
// required: true
// - name: id
// in: path
// description: id of the milestone
// type: integer
// required: true
// - name: body
// in: body
// schema:
@@ -202,7 +207,7 @@ func DeleteMilestone(ctx *context.APIContext) {
// description: name of the repo
// type: string
// required: true
// - name: body
// - name: id
// in: path
// description: id of the milestone to delete
// type: integer