diff --git a/modules/structs/project.go b/modules/structs/project.go index d546021910..1b850504d9 100644 --- a/modules/structs/project.go +++ b/modules/structs/project.go @@ -22,6 +22,7 @@ type Project struct { } type CreateProjectOption struct { + // required:true Title string `json:"title" binding:"Required;MaxSize(100)"` Content string `json:"content"` TemplateType uint8 `json:"template_type"` diff --git a/routers/api/v1/shared/project.go b/routers/api/v1/shared/project.go index 63fb629fdf..4858ec0676 100644 --- a/routers/api/v1/shared/project.go +++ b/routers/api/v1/shared/project.go @@ -41,6 +41,34 @@ func ProjectHandler(model string, fn func(ctx *context.APIContext, model string) // CreateProject creates a new project func CreateProject(ctx *context.APIContext, model string) { + // swagger: operation POST /users/{username}/{reponame}/projects project createProject + // --- + // summary: Create a project + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: owner of the project + // type: string + // required: true + // - name: reponame + // in: path + // description: repository name + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateProjectOption" + // responses: + // "200": + // "$ref": "#/responses/Project" + // "404": + // "$ref": "#/responses/notFound" + err := checkModelType(model) if err != nil { diff --git a/routers/api/v1/swagger/options.go b/routers/api/v1/swagger/options.go index 1de58632d5..c9ee3102fc 100644 --- a/routers/api/v1/swagger/options.go +++ b/routers/api/v1/swagger/options.go @@ -205,4 +205,7 @@ type swaggerParameterBodies struct { // in:body UpdateVariableOption api.UpdateVariableOption + + // in:body + CreateProjectOption api.CreateProjectOption } diff --git a/routers/api/v1/swagger/project.go b/routers/api/v1/swagger/project.go new file mode 100644 index 0000000000..90e1abd338 --- /dev/null +++ b/routers/api/v1/swagger/project.go @@ -0,0 +1,15 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package swagger + +import ( + api "code.gitea.io/gitea/modules/structs" +) + +// Project +// swagger:response Project +type swaggerResponseProject struct { + // in:body + Body api.Project `json:"body"` +}