From f26f4a7e01f9c380c261fa5bc21bd7e48f2f2f9f Mon Sep 17 00:00:00 2001 From: Ethan Koenig Date: Sun, 12 Nov 2017 23:02:25 -0800 Subject: [PATCH] Update swagger documentation (#2899) * Update swagger documentation Add docs for missing endpoints Add documentation for request parameters Make parameter naming consistent Fix response documentation * Restore delete comments --- Makefile | 2 - modules/auth/repo_form.go | 13 +- public/swagger.v1.json | 6787 +++++++++++++---- routers/api/v1/admin/org.go | 34 +- routers/api/v1/admin/repo.go | 34 +- routers/api/v1/admin/user.go | 139 +- routers/api/v1/api.go | 23 +- routers/api/v1/misc/markdown.go | 50 +- routers/api/v1/misc/version.go | 20 +- routers/api/v1/org/hook.go | 100 +- routers/api/v1/org/member.go | 201 +- routers/api/v1/org/org.go | 59 +- routers/api/v1/org/team.go | 198 + routers/api/v1/repo/branch.go | 45 +- routers/api/v1/repo/collaborators.go | 99 +- routers/api/v1/repo/file.go | 71 +- routers/api/v1/repo/fork.go | 62 +- routers/api/v1/repo/hook.go | 159 +- routers/api/v1/repo/issue.go | 106 + routers/api/v1/repo/issue_comment.go | 135 +- routers/api/v1/repo/issue_label.go | 139 + routers/api/v1/repo/issue_tracked_time.go | 158 +- routers/api/v1/repo/key.go | 94 +- routers/api/v1/repo/label.go | 120 + routers/api/v1/repo/milestone.go | 115 + routers/api/v1/repo/pull.go | 157 +- routers/api/v1/repo/release.go | 120 + routers/api/v1/repo/repo.go | 276 +- routers/api/v1/repo/star.go | 19 + routers/api/v1/repo/status.go | 122 +- routers/api/v1/repo/subscriber.go | 19 + routers/api/v1/swagger/issue.go | 69 + routers/api/v1/swagger/key.go | 45 + routers/api/v1/swagger/misc.go | 15 + routers/api/v1/swagger/options.go | 66 + routers/api/v1/swagger/org.go | 33 + routers/api/v1/swagger/repo.go | 92 + routers/api/v1/swagger/user.go | 33 + routers/api/v1/user/app.go | 39 +- routers/api/v1/user/email.go | 47 +- routers/api/v1/user/follower.go | 177 +- routers/api/v1/user/gpg_key.go | 133 +- routers/api/v1/user/key.go | 130 +- routers/api/v1/user/repo.go | 62 +- routers/api/v1/user/star.go | 114 +- routers/api/v1/user/user.go | 70 +- routers/api/v1/user/watch.go | 108 +- vendor/code.gitea.io/sdk/gitea/admin_user.go | 29 +- vendor/code.gitea.io/sdk/gitea/attachment.go | 17 + vendor/code.gitea.io/sdk/gitea/fork.go | 3 +- vendor/code.gitea.io/sdk/gitea/hook.go | 30 +- vendor/code.gitea.io/sdk/gitea/issue.go | 15 +- .../code.gitea.io/sdk/gitea/issue_comment.go | 10 +- vendor/code.gitea.io/sdk/gitea/issue_label.go | 14 +- .../sdk/gitea/issue_milestone.go | 7 +- .../sdk/gitea/issue_tracked_time.go | 9 +- .../code.gitea.io/sdk/gitea/miscellaneous.go | 10 +- vendor/code.gitea.io/sdk/gitea/org.go | 14 +- vendor/code.gitea.io/sdk/gitea/org_team.go | 11 +- vendor/code.gitea.io/sdk/gitea/pull.go | 9 +- vendor/code.gitea.io/sdk/gitea/release.go | 3 + vendor/code.gitea.io/sdk/gitea/repo.go | 45 +- vendor/code.gitea.io/sdk/gitea/repo_branch.go | 2 +- .../sdk/gitea/repo_collaborator.go | 2 +- vendor/code.gitea.io/sdk/gitea/repo_key.go | 6 +- vendor/code.gitea.io/sdk/gitea/repo_watch.go | 3 +- vendor/code.gitea.io/sdk/gitea/status.go | 2 + vendor/code.gitea.io/sdk/gitea/user.go | 13 +- vendor/code.gitea.io/sdk/gitea/user_email.go | 14 +- vendor/code.gitea.io/sdk/gitea/user_gpgkey.go | 9 +- vendor/code.gitea.io/sdk/gitea/user_key.go | 6 +- vendor/vendor.json | 6 +- 72 files changed, 8875 insertions(+), 2323 deletions(-) create mode 100644 routers/api/v1/swagger/issue.go create mode 100644 routers/api/v1/swagger/key.go create mode 100644 routers/api/v1/swagger/misc.go create mode 100644 routers/api/v1/swagger/options.go create mode 100644 routers/api/v1/swagger/org.go create mode 100644 routers/api/v1/swagger/repo.go create mode 100644 routers/api/v1/swagger/user.go create mode 100644 vendor/code.gitea.io/sdk/gitea/attachment.go diff --git a/Makefile b/Makefile index 8ac3940b85..4485986ffd 100644 --- a/Makefile +++ b/Makefile @@ -89,8 +89,6 @@ generate-swagger: $(GO) get -u github.com/go-swagger/go-swagger/cmd/swagger; \ fi swagger generate spec -o ./public/swagger.v1.json - $(SED_INPLACE) "s;\".ref\": \"#/definitions/GPGKey\";\"type\": \"object\";g" ./public/swagger.v1.json - $(SED_INPLACE) "s;^ \".ref\": \"#/definitions/Repository\"; \"type\": \"object\";g" ./public/swagger.v1.json .PHONY: errcheck errcheck: diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index a6454655f7..6fe826f574 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -41,14 +41,17 @@ func (f *CreateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) bin // MigrateRepoForm form for migrating repository type MigrateRepoForm struct { + // required: true CloneAddr string `json:"clone_addr" binding:"Required"` AuthUsername string `json:"auth_username"` AuthPassword string `json:"auth_password"` - UID int64 `json:"uid" binding:"Required"` - RepoName string `json:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"` - Mirror bool `json:"mirror"` - Private bool `json:"private"` - Description string `json:"description" binding:"MaxSize(255)"` + // required: true + UID int64 `json:"uid" binding:"Required"` + // required: true + RepoName string `json:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"` + Mirror bool `json:"mirror"` + Private bool `json:"private"` + Description string `json:"description" binding:"MaxSize(255)"` } // Validate validates the fields diff --git a/public/swagger.v1.json b/public/swagger.v1.json index c269fcb864..4f4505b4a1 100644 --- a/public/swagger.v1.json +++ b/public/swagger.v1.json @@ -13,9 +13,8 @@ ], "swagger": "2.0", "info": { - "description": "This provide API interface to communicate with this Gitea instance.", + "description": "This documentation describes the Gitea API.", "title": "Gitea API.", - "termsOfService": "there are no TOS at this moment, use at your own risk we take no responsibility", "license": { "name": "MIT", "url": "http://opensource.org/licenses/MIT" @@ -35,63 +34,14 @@ "tags": [ "admin" ], + "summary": "Create a user", "operationId": "adminCreateUser", "parameters": [ { - "x-go-name": "SourceID", - "name": "source_id", + "name": "body", "in": "body", "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "x-go-name": "LoginName", - "name": "login_name", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Username", - "name": "username", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "FullName", - "name": "full_name", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Email", - "name": "email", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Password", - "name": "password", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "SendNotify", - "name": "send_notify", - "in": "body", - "schema": { - "type": "boolean" + "$ref": "#/definitions/CreateUserOption" } } ], @@ -104,9 +54,6 @@ }, "422": { "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -119,7 +66,17 @@ "tags": [ "admin" ], + "summary": "Delete a user", "operationId": "adminDeleteUser", + "parameters": [ + { + "type": "string", + "description": "username of user to delete", + "name": "username", + "in": "path", + "required": true + } + ], "responses": { "204": { "$ref": "#/responses/empty" @@ -129,9 +86,6 @@ }, "422": { "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } }, @@ -145,104 +99,21 @@ "tags": [ "admin" ], + "summary": "Edit an existing user", "operationId": "adminEditUser", "parameters": [ { - "x-go-name": "SourceID", - "name": "source_id", - "in": "body", - "schema": { - "type": "integer", - "format": "int64" - } + "type": "string", + "description": "username of user to edit", + "name": "username", + "in": "path", + "required": true }, { - "x-go-name": "LoginName", - "name": "login_name", + "name": "body", "in": "body", "schema": { - "type": "string" - } - }, - { - "x-go-name": "FullName", - "name": "full_name", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Email", - "name": "email", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Password", - "name": "password", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Website", - "name": "website", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Location", - "name": "location", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Active", - "name": "active", - "in": "body", - "schema": { - "type": "boolean" - } - }, - { - "x-go-name": "Admin", - "name": "admin", - "in": "body", - "schema": { - "type": "boolean" - } - }, - { - "x-go-name": "AllowGitHook", - "name": "allow_git_hook", - "in": "body", - "schema": { - "type": "boolean" - } - }, - { - "x-go-name": "AllowImportLocal", - "name": "allow_import_local", - "in": "body", - "schema": { - "type": "boolean" - } - }, - { - "x-go-name": "MaxRepoCreation", - "name": "max_repo_creation", - "in": "body", - "schema": { - "type": "integer", - "format": "int64" + "$ref": "#/definitions/EditUserOption" } } ], @@ -255,9 +126,6 @@ }, "422": { "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -273,29 +141,15 @@ "tags": [ "admin" ], + "summary": "Add a public key on behalf of a user", "operationId": "adminCreatePublicKey", "parameters": [ { - "uniqueItems": true, - "x-go-name": "Title", - "description": "Title of the key to add", - "name": "title", - "in": "body", - "required": true, - "schema": { - "type": "string" - } - }, - { - "uniqueItems": true, - "x-go-name": "Key", - "description": "An armored SSH key to add", - "name": "key", - "in": "body", - "required": true, - "schema": { - "type": "string" - } + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true } ], "responses": { @@ -307,9 +161,6 @@ }, "422": { "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -325,47 +176,15 @@ "tags": [ "admin" ], + "summary": "Create an organization", "operationId": "adminCreateOrg", "parameters": [ { - "x-go-name": "UserName", + "type": "string", + "description": "username of the user that will own the created organization", "name": "username", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "FullName", - "name": "full_name", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Description", - "name": "description", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Website", - "name": "website", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Location", - "name": "location", - "in": "body", - "schema": { - "type": "string" - } + "in": "path", + "required": true } ], "responses": { @@ -377,9 +196,6 @@ }, "422": { "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -395,71 +211,15 @@ "tags": [ "admin" ], + "summary": "Create a repository on behalf a user", "operationId": "adminCreateRepo", "parameters": [ { - "uniqueItems": true, - "x-go-name": "Name", - "description": "Name of the repository to create", - "name": "name", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Description", - "description": "Description of the repository to create", - "name": "description", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Private", - "description": "Is the repository to create private ?", - "name": "private", - "in": "body", - "schema": { - "type": "boolean" - } - }, - { - "x-go-name": "AutoInit", - "description": "Init the repository to create ?", - "name": "auto_init", - "in": "body", - "schema": { - "type": "boolean" - } - }, - { - "x-go-name": "Gitignores", - "description": "Gitignores to use", - "name": "gitignores", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "License", - "description": "License to use", - "name": "license", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Readme", - "description": "Readme of the repository to create", - "name": "readme", - "in": "body", - "schema": { - "type": "string" - } + "type": "string", + "description": "username of the user. This user will own the created repository", + "name": "username", + "in": "path", + "required": true } ], "responses": { @@ -471,9 +231,6 @@ }, "422": { "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -489,38 +246,14 @@ "tags": [ "miscellaneous" ], + "summary": "Render a markdown document as HTML", "operationId": "renderMarkdown", "parameters": [ { - "description": "Text markdown to render", - "name": "Text", + "name": "body", "in": "body", "schema": { - "type": "string" - } - }, - { - "description": "Mode to render", - "name": "Mode", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "description": "Context to render", - "name": "Context", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "description": "Is it a wiki page ?", - "name": "Wiki", - "in": "body", - "schema": { - "type": "boolean" + "$ref": "#/definitions/MarkdownOption" } } ], @@ -545,7 +278,15 @@ "tags": [ "miscellaneous" ], + "summary": "Render raw markdown as HTML", "operationId": "renderMarkdownRaw", + "parameters": [ + { + "type": "string", + "name": "body", + "in": "body" + } + ], "responses": { "200": { "$ref": "#/responses/MarkdownRender" @@ -567,70 +308,21 @@ "tags": [ "organization" ], + "summary": "Create a repository in an organization", "operationId": "createOrgRepo", "parameters": [ { - "uniqueItems": true, - "x-go-name": "Name", - "description": "Name of the repository to create", - "name": "name", - "in": "body", - "schema": { - "type": "string" - } + "type": "string", + "description": "name of organization", + "name": "org", + "in": "path", + "required": true }, { - "x-go-name": "Description", - "description": "Description of the repository to create", - "name": "description", + "name": "body", "in": "body", "schema": { - "type": "string" - } - }, - { - "x-go-name": "Private", - "description": "Is the repository to create private ?", - "name": "private", - "in": "body", - "schema": { - "type": "boolean" - } - }, - { - "x-go-name": "AutoInit", - "description": "Init the repository to create ?", - "name": "auto_init", - "in": "body", - "schema": { - "type": "boolean" - } - }, - { - "x-go-name": "Gitignores", - "description": "Gitignores to use", - "name": "gitignores", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "License", - "description": "License to use", - "name": "license", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Readme", - "description": "Readme of the repository to create", - "name": "readme", - "in": "body", - "schema": { - "type": "string" + "$ref": "#/definitions/CreateRepoOption" } } ], @@ -643,14 +335,11 @@ }, "422": { "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } } }, - "/orgs/{orgname}/hooks": { + "/orgs/{org}": { "get": { "produces": [ "application/json" @@ -658,120 +347,20 @@ "tags": [ "organization" ], - "operationId": "orgListHooks", - "responses": { - "200": { - "$ref": "#/responses/HookList" - }, - "500": { - "$ref": "#/responses/error" - } - } - } - }, - "/orgs/{orgname}/hooks/": { - "post": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "organization" - ], - "operationId": "orgCreateHook", + "summary": "Get an organization", + "operationId": "orgGet", "parameters": [ { - "x-go-name": "Type", - "name": "type", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Config", - "name": "config", - "in": "body", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - { - "x-go-name": "Events", - "name": "events", - "in": "body", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "x-go-name": "Active", - "name": "active", - "in": "body", - "schema": { - "type": "boolean" - } + "type": "string", + "description": "name of the organization to get", + "name": "org", + "in": "path", + "required": true } ], - "responses": { - "201": { - "$ref": "#/responses/Hook" - }, - "422": { - "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" - } - } - } - }, - "/orgs/{orgname}/hooks/{id}": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "organization" - ], - "operationId": "orgGetHook", "responses": { "200": { - "$ref": "#/responses/Hook" - }, - "404": { - "$ref": "#/responses/notFound" - }, - "500": { - "$ref": "#/responses/error" - } - } - }, - "delete": { - "produces": [ - "application/json" - ], - "tags": [ - "organization" - ], - "operationId": "orgDeleteHook", - "responses": { - "204": { - "$ref": "#/responses/empty" - }, - "404": { - "$ref": "#/responses/notFound" - }, - "500": { - "$ref": "#/responses/error" + "$ref": "#/responses/Organization" } } }, @@ -785,92 +374,81 @@ "tags": [ "organization" ], - "operationId": "orgEditHook", + "summary": "Edit an organization", + "operationId": "orgEdit", "parameters": [ { - "x-go-name": "Config", - "name": "config", - "in": "body", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } + "type": "string", + "description": "name of the organization to edit", + "name": "org", + "in": "path", + "required": true }, { - "x-go-name": "Events", - "name": "events", + "name": "body", "in": "body", "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "x-go-name": "Active", - "name": "active", - "in": "body", - "schema": { - "type": "boolean" + "$ref": "#/definitions/EditOrgOption" } } ], + "responses": { + "200": { + "$ref": "#/responses/Organization" + } + } + } + }, + "/orgs/{org}/hooks": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List an organization's webhooks", + "operationId": "orgListHooks", + "responses": { + "200": { + "$ref": "#/responses/HookList" + } + } + } + }, + "/orgs/{org}/hooks/": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Create a hook", + "operationId": "orgCreateHook", + "responses": { + "201": { + "$ref": "#/responses/Hook" + } + } + } + }, + "/orgs/{org}/hooks/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Get a hook", + "operationId": "orgGetHook", "responses": { "200": { "$ref": "#/responses/Hook" - }, - "404": { - "$ref": "#/responses/notFound" - }, - "422": { - "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" - } - } - } - }, - "/orgs/{orgname}/members": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "organization" - ], - "operationId": "orgListMembers", - "responses": { - "200": { - "$ref": "#/responses/UserList" - }, - "500": { - "$ref": "#/responses/error" - } - } - } - }, - "/orgs/{orgname}/members/{username}": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "organization" - ], - "operationId": "orgIsMember", - "responses": { - "204": { - "$ref": "#/responses/empty" - }, - "302": { - "$ref": "#/responses/redirect" - }, - "404": { - "$ref": "#/responses/notFound" } } }, @@ -881,18 +459,34 @@ "tags": [ "organization" ], - "operationId": "orgDeleteMember", + "summary": "Delete a hook", + "operationId": "orgDeleteHook", "responses": { "204": { "$ref": "#/responses/empty" - }, - "500": { - "$ref": "#/responses/error" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Update a hook", + "operationId": "orgEditHook", + "responses": { + "200": { + "$ref": "#/responses/Hook" } } } }, - "/orgs/{orgname}/public_members": { + "/orgs/{org}/members": { "get": { "produces": [ "application/json" @@ -900,18 +494,98 @@ "tags": [ "organization" ], - "operationId": "orgListPublicMembers", + "summary": "List an organization's members", + "operationId": "orgListMembers", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + } + ], "responses": { "200": { "$ref": "#/responses/UserList" - }, - "500": { - "$ref": "#/responses/error" } } } }, - "/orgs/{orgname}/public_members/{username}": { + "/orgs/{org}/members/{username}": { + "get": { + "tags": [ + "organization" + ], + "summary": "Check if a user is a member of an organization", + "operationId": "orgIsMember", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "user is a member", + "schema": { + "$ref": "#/responses/empty" + } + }, + "404": { + "description": "user is not a member", + "schema": { + "$ref": "#/responses/empty" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Remove a member from an organization", + "operationId": "orgDeleteMember", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "member removed", + "schema": { + "$ref": "#/responses/empty" + } + } + } + } + }, + "/orgs/{org}/public_members": { "get": { "produces": [ "application/json" @@ -919,13 +593,59 @@ "tags": [ "organization" ], + "summary": "List an organization's public members", + "operationId": "orgListPublicMembers", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/UserList" + } + } + } + }, + "/orgs/{org}/public_members/{username}": { + "get": { + "tags": [ + "organization" + ], + "summary": "Check if a user is a public member of an organization", "operationId": "orgIsPublicMember", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], "responses": { "204": { - "$ref": "#/responses/empty" + "description": "user is a public member", + "schema": { + "$ref": "#/responses/empty" + } }, "404": { - "$ref": "#/responses/notFound" + "description": "user is not a public member", + "schema": { + "$ref": "#/responses/empty" + } } } }, @@ -936,16 +656,30 @@ "tags": [ "organization" ], + "summary": "Publicize a user's membership", "operationId": "orgPublicizeMember", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], "responses": { "204": { - "$ref": "#/responses/empty" - }, - "403": { - "$ref": "#/responses/forbidden" - }, - "500": { - "$ref": "#/responses/error" + "description": "membership publicized", + "schema": { + "$ref": "#/responses/empty" + } } } }, @@ -956,21 +690,32 @@ "tags": [ "organization" ], + "summary": "Conceal a user's membership", "operationId": "orgConcealMember", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], "responses": { "204": { "$ref": "#/responses/empty" - }, - "403": { - "$ref": "#/responses/forbidden" - }, - "500": { - "$ref": "#/responses/error" } } } }, - "/orgs/{orgname}/repos": { + "/orgs/{org}/repos": { "get": { "produces": [ "application/json" @@ -978,13 +723,80 @@ "tags": [ "organization" ], + "summary": "List an organization's repos", "operationId": "orgListRepos", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + } + ], "responses": { "200": { "$ref": "#/responses/RepositoryList" + } + } + } + }, + "/orgs/{org}/teams": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List an organization's teams", + "operationId": "orgListTeams", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/TeamList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Create a team", + "operationId": "orgCreateTeam", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true }, - "500": { - "$ref": "#/responses/error" + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateTeamOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Team" } } } @@ -1000,83 +812,20 @@ "tags": [ "repository" ], + "summary": "Migrate a remote git repository", "operationId": "repoMigrate", "parameters": [ { - "x-go-name": "CloneAddr", - "name": "clone_addr", + "name": "body", "in": "body", "schema": { - "type": "string" - } - }, - { - "x-go-name": "AuthUsername", - "name": "auth_username", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "AuthPassword", - "name": "auth_password", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "UID", - "name": "uid", - "in": "body", - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "x-go-name": "RepoName", - "name": "repo_name", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Mirror", - "name": "mirror", - "in": "body", - "schema": { - "type": "boolean" - } - }, - { - "x-go-name": "Private", - "name": "private", - "in": "body", - "schema": { - "type": "boolean" - } - }, - { - "x-go-name": "Description", - "name": "description", - "in": "body", - "schema": { - "type": "string" + "$ref": "#/definitions/MigrateRepoForm" } } ], "responses": { "201": { "$ref": "#/responses/Repository" - }, - "422": { - "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -1089,42 +838,36 @@ "tags": [ "repository" ], + "summary": "Search for repositories", "operationId": "repoSearch", "parameters": [ { "type": "string", - "x-go-name": "Keyword", - "description": "Keyword to search", + "description": "keyword", "name": "q", "in": "query" }, { "type": "integer", - "format": "int64", - "x-go-name": "OwnerID", - "description": "Repository owner to search", + "description": "if provided, will return only repos owned by the user with the given id", "name": "uid", "in": "query" }, { "type": "integer", - "format": "int64", - "x-go-name": "PageSize", - "description": "Limit of result\n\nmaximum: setting.ExplorePagingNum", + "description": "maximum number of repos to return", "name": "limit", "in": "query" }, { "type": "string", - "x-go-name": "SearchMode", - "description": "Type of repository to search, related to owner", + "description": "type of repository to search for. Supported values are \"fork\", \"source\", \"mirror\" and \"collaborative\"", "name": "mode", "in": "query" }, { "type": "boolean", - "x-go-name": "OwnerExclusive", - "description": "Search only owners repositories\nHas effect only if owner is provided and mode is not \"collaborative\"", + "description": "only search for repositories owned by the authenticated user", "name": "exclusive", "in": "query" } @@ -1135,13 +878,510 @@ }, "422": { "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/SearchError" } } } }, + "/repos/{owner}/{repo}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a repository", + "operationId": "repoGet", + "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 + } + ], + "responses": { + "200": { + "$ref": "#/responses/Repository" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a repository", + "operationId": "repoDelete", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to delete", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to delete", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + } + }, + "/repos/{owner}/{repo}/archive/{filepath}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get an archive of a repository", + "operationId": "repoGetArchive", + "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": "string", + "description": "archive to download, consisting of a git reference and archive", + "name": "archive", + "in": "path", + "required": true + } + ], + "responses": { + "200": {} + } + } + }, + "/repos/{owner}/{repo}/branches": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repository's branches", + "operationId": "repoListBranches", + "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 + } + ], + "responses": { + "200": { + "$ref": "#/responses/BranchList" + } + } + } + }, + "/repos/{owner}/{repo}/branches/{branch}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repository's branches", + "operationId": "repoGetBranch", + "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": "string", + "description": "branch to get", + "name": "branch", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Branch" + } + } + } + }, + "/repos/{owner}/{repo}/collaborators": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repository's collaborators", + "operationId": "repoListCollaborators", + "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 + } + ], + "responses": { + "200": { + "$ref": "#/responses/UserList" + } + } + } + }, + "/repos/{owner}/{repo}/collaborators/{collaborator}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Check if a user is a collaborator of a repository", + "operationId": "repoCheckCollaborator", + "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": "string", + "description": "username of the collaborator", + "name": "collaborator", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/empty" + } + } + }, + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Add a collaborator to a repository", + "operationId": "repoAddCollaborator", + "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": "string", + "description": "username of the collaborator to add", + "name": "collaborator", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/AddCollaboratorOption" + } + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a collaborator from a repository", + "operationId": "repoDeleteCollaborator", + "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": "string", + "description": "username of the collaborator to delete", + "name": "collaborator", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + } + }, + "/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": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a commit's combined status, by branch/tag/commit reference", + "operationId": "repoGetCombinedStatusByRef", + "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": "string", + "description": "name of branch/tag/commit", + "name": "ref", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Status" + } + } + } + }, + "/repos/{owner}/{repo}/editorconfig/{filepath}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get the EditorConfig definitions of a file in a repository", + "operationId": "repoGetEditorConfig", + "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": "string", + "description": "filepath of file to get", + "name": "filepath", + "in": "path", + "required": true + } + ], + "responses": { + "200": {} + } + } + }, "/repos/{owner}/{repo}/forks": { "get": { "produces": [ @@ -1150,13 +1390,27 @@ "tags": [ "repository" ], + "summary": "List a repository's forks", "operationId": "listForks", + "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 + } + ], "responses": { "200": { "$ref": "#/responses/RepositoryList" - }, - "500": { - "$ref": "#/responses/error" } } }, @@ -1167,73 +1421,39 @@ "tags": [ "repository" ], + "summary": "Fork a repository", "operationId": "createFork", "parameters": [ { - "x-go-name": "Organization", - "name": "organization", + "type": "string", + "description": "owner of the repo to fork", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to fork", + "name": "repo", + "in": "path", + "required": true + }, + { + "name": "body", "in": "body", "schema": { - "type": "string" + "$ref": "#/definitions/CreateForkOption" } } ], "responses": { "202": { "$ref": "#/responses/Repository" - }, - "403": { - "$ref": "#/responses/forbidden" - }, - "422": { - "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } } }, - "/repos/{username}/{reponame}": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "repository" - ], - "operationId": "repoGet", - "responses": { - "200": { - "$ref": "#/responses/Repository" - }, - "500": { - "$ref": "#/responses/error" - } - } - }, - "delete": { - "produces": [ - "application/json" - ], - "tags": [ - "repository" - ], - "operationId": "repoDelete", - "responses": { - "204": { - "$ref": "#/responses/empty" - }, - "403": { - "$ref": "#/responses/forbidden" - }, - "500": { - "$ref": "#/responses/error" - } - } - } - }, - "/repos/{username}/{reponame}/hooks": { + "/repos/{owner}/{repo}/hooks": { "get": { "produces": [ "application/json" @@ -1241,13 +1461,27 @@ "tags": [ "repository" ], + "summary": "List the hooks in a repository", "operationId": "repoListHooks", + "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 + } + ], "responses": { "200": { "$ref": "#/responses/HookList" - }, - "500": { - "$ref": "#/responses/error" } } }, @@ -1261,78 +1495,74 @@ "tags": [ "repository" ], + "summary": "Create a hook", "operationId": "repoCreateHook", "parameters": [ { - "x-go-name": "Type", - "name": "type", - "in": "body", - "schema": { - "type": "string" - } + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true }, { - "x-go-name": "Config", - "name": "config", - "in": "body", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true }, { - "x-go-name": "Events", - "name": "events", + "name": "body", "in": "body", "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "x-go-name": "Active", - "name": "active", - "in": "body", - "schema": { - "type": "boolean" + "$ref": "#/definitions/CreateHookOption" } } ], "responses": { "200": { "$ref": "#/responses/Hook" - }, - "422": { - "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } } }, - "/repos/{username}/{reponame}/hooks/{id}": { - "delete": { + "/repos/{owner}/{repo}/hooks/{id}": { + "get": { "produces": [ "application/json" ], "tags": [ "repository" ], - "operationId": "repoDeleteHook", + "summary": "Get a hook", + "operationId": "repoGetHook", + "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 hook to get", + "name": "id", + "in": "path", + "required": true + } + ], "responses": { - "204": { - "$ref": "#/responses/empty" - }, - "404": { - "$ref": "#/responses/notFound" - }, - "500": { - "$ref": "#/responses/error" + "200": { + "$ref": "#/responses/Hook" } } }, @@ -1343,89 +1573,651 @@ "tags": [ "repository" ], + "summary": "Edit a hook in a repository", "operationId": "repoEditHook", "parameters": [ { - "x-go-name": "Config", - "name": "config", - "in": "body", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true }, { - "x-go-name": "Events", - "name": "events", - "in": "body", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true }, { - "x-go-name": "Active", - "name": "active", + "name": "body", "in": "body", "schema": { - "type": "boolean" + "$ref": "#/definitions/EditHookOption" } } ], "responses": { "200": { "$ref": "#/responses/Hook" - }, - "422": { - "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } } }, - "/repos/{username}/{reponame}/issues/{issue}/times": { + "/repos/{owner}/{repo}/issue/{index}/comments": { "get": { "produces": [ "application/json" ], "tags": [ - "repository" + "issue" + ], + "summary": "List all comments on an issue", + "operationId": "issueGetComments", + "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": "index of the issue", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "if provided, only comments updated since the specified time are returned.", + "name": "string", + "in": "query" + } ], - "operationId": "issueTrackedTimes", "responses": { "200": { - "$ref": "#/responses/TrackedTimes" - }, - "404": { - "$ref": "#/responses/error" - }, - "500": { - "$ref": "#/responses/error" + "$ref": "#/responses/CommentList" } } - }, - "post": { + } + }, + "/repos/{owner}/{repo}/issue/{index}/labels": { + "put": { + "consumes": [ + "application/json" + ], "produces": [ "application/json" ], "tags": [ - "repository" + "issue" ], - "operationId": "addTime", + "summary": "Replace an issue's labels", + "operationId": "issueReplaceLabels", "parameters": [ { - "x-go-name": "Time", - "name": "time", + "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": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", "in": "body", "schema": { - "type": "integer", - "format": "int64" + "$ref": "#/definitions/IssueLabelsOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/LabelList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Add a label to an issue", + "operationId": "issueAddLabel", + "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": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/IssueLabelsOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/LabelList" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Remove all labels from an issue", + "operationId": "issueClearLabels", + "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": "index of the issue", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + } + }, + "/repos/{owner}/{repo}/issue/{index}/labels/{id}": { + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Remove a label from an issue", + "operationId": "issueRemoveLabel", + "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": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "id of the label to remove", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + } + }, + "/repos/{owner}/{repo}/issues": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List a repository's issues", + "operationId": "issueListIssues", + "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": "string", + "description": "whether issue is open or closed", + "name": "state", + "in": "query" + }, + { + "type": "integer", + "description": "page number of requested issues", + "name": "page", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/IssueList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Create an issue", + "operationId": "issueCreateIssue", + "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 + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateIssueOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Issue" + } + } + } + }, + "/repos/{owner}/{repo}/issues/comments": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List all comments in a repository", + "operationId": "issueGetRepoComments", + "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": "string", + "description": "if provided, only comments updated since the provided time are returned.", + "name": "string", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/CommentList" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get an issue by id", + "operationId": "issueGetIssue", + "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 issue to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Issue" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Edit an issue", + "operationId": "issueEditIssue", + "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 issue to edit", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditIssueOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Issue" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/comments": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Add a comment to an issue", + "operationId": "issueCreateComment", + "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": "index of the issue", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateIssueOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Comment" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/labels": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get an issue's labels", + "operationId": "issueGetLabels", + "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": "index of the issue", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/LabelList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/times": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List an issue's tracked times", + "operationId": "issueTrackedTimes", + "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": "index of the issue", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/TrackedTimeList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Add a tracked time to a issue", + "operationId": "issueAddTime", + "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": "index of the issue to add tracked time to", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/AddTimeOption" } } ], @@ -1438,61 +2230,120 @@ }, "403": { "$ref": "#/responses/error" - }, - "404": { - "$ref": "#/responses/error" - }, - "500": { - "$ref": "#/responses/error" } } } }, - "/repos/{username}/{reponame}/mirror-sync": { - "post": { + "/repos/{owner}/{repo}/keys": { + "get": { "produces": [ "application/json" ], "tags": [ "repository" ], - "operationId": "repoMirrorSync", + "summary": "List a repository's keys", + "operationId": "repoListKeys", + "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 + } + ], "responses": { "200": { - "$ref": "#/responses/empty" + "$ref": "#/responses/DeployKeyList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Add a key to a repository", + "operationId": "repoCreateKey", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true }, - "403": { - "$ref": "#/responses/forbidden" + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateKeyOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/DeployKey" } } } }, - "/repos/{username}/{reponame}/subscription": { + "/repos/{owner}/{repo}/keys/{id}": { "get": { + "produces": [ + "application/json" + ], "tags": [ "repository" ], - "operationId": "userCurrentCheckSubscription", - "responses": { - "200": { - "$ref": "#/responses/WatchInfo" + "summary": "Get a repository's key by id", + "operationId": "repoGetKey", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true }, - "404": { - "$ref": "#/responses/notFound" + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "id of the key to get", + "name": "id", + "in": "path", + "required": true } - } - }, - "put": { - "tags": [ - "repository" ], - "operationId": "userCurrentPutSubscription", "responses": { "200": { - "$ref": "#/responses/WatchInfo" - }, - "500": { - "$ref": "#/responses/error" + "$ref": "#/responses/DeployKey" } } }, @@ -1500,18 +2351,443 @@ "tags": [ "repository" ], - "operationId": "userCurrentDeleteSubscription", + "summary": "Delete a key from a repository", + "operationId": "repoDeleteKey", + "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 key to delete", + "name": "id", + "in": "path", + "required": true + } + ], "responses": { "204": { "$ref": "#/responses/empty" - }, - "500": { - "$ref": "#/responses/error" } } } }, - "/repos/{username}/{reponame}/times": { + "/repos/{owner}/{repo}/labels": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get all of a repository's labels", + "operationId": "issueListLabels", + "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 + } + ], + "responses": { + "200": { + "$ref": "#/responses/LabelList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Create a label", + "operationId": "issueCreateLabel", + "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 + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateLabelOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Label" + } + } + } + }, + "/repos/{owner}/{repo}/labels/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get a single label", + "operationId": "issueGetLabel", + "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 label to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Label" + } + } + }, + "delete": { + "tags": [ + "issue" + ], + "summary": "Delete a label", + "operationId": "issueDeleteLabel", + "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 label to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Update a label", + "operationId": "issueEditLabel", + "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 label to edit", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditLabelOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Label" + } + } + } + }, + "/repos/{owner}/{repo}/milestones": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get all of a repository's milestones", + "operationId": "issueGetMilestones", + "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 milestone to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/MilestoneList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Create a milestone", + "operationId": "issueCreateMilestone", + "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 + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateMilestoneOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Milestone" + } + } + } + }, + "/repos/{owner}/{repo}/milestones/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get a milestone", + "operationId": "issueGetMilestone", + "responses": { + "200": { + "$ref": "#/responses/Milestone" + } + } + }, + "delete": { + "tags": [ + "issue" + ], + "summary": "Delete a milestone", + "operationId": "issueDeleteMilestone", + "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 milestone to delete", + "name": "body", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Update a milestone", + "operationId": "issueEditMilestone", + "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 + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditMilestoneOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Milestone" + } + } + } + }, + "/repos/{owner}/{repo}/mirror-sync": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Sync a mirrored repository", + "operationId": "repoMirrorSync", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to sync", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to sync", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/empty" + } + } + } + }, + "/repos/{owner}/{repo}/pulls": { "get": { "produces": [ "application/json" @@ -1519,21 +2795,687 @@ "tags": [ "repository" ], - "operationId": "repoTrackedTimes", + "summary": "List a repo's pull requests", + "operationId": "repoListPullRequests", + "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 + } + ], "responses": { "200": { - "$ref": "#/responses/TrackedTimes" + "$ref": "#/responses/PullRequestList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a pull request", + "operationId": "repoCreatePullRequest", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true }, - "400": { - "$ref": "#/responses/error" + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true }, - "500": { - "$ref": "#/responses/error" + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreatePullRequestOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/PullRequest" } } } }, - "/repos/{username}/{reponame}/times/{timetrackingusername}": { + "/repos/{owner}/{repo}/pulls/{index}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a pull request", + "operationId": "repoGetPullRequest", + "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": "index of the pull request to get", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/PullRequest" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Update a pull request", + "operationId": "repoEditPullRequest", + "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": "index of the pull request to edit", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditPullRequestOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/PullRequest" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/{index}/merge": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Check if a pull request has been merged", + "operationId": "repoPullRequestIsMerged", + "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": "index of the pull request", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "pull request has been merged", + "schema": { + "$ref": "#/responses/empty" + } + }, + "404": { + "description": "pull request has not been merged", + "schema": { + "$ref": "#/responses/empty" + } + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Merge a pull request", + "operationId": "repoMergePullRequest", + "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": "index of the pull request to merge", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/empty" + }, + "405": { + "$ref": "#/responses/empty" + } + } + } + }, + "/repos/{owner}/{repo}/raw/{filepath}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a file from a repository", + "operationId": "repoGetRawFile", + "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": "string", + "description": "filepath of the file to get", + "name": "filepath", + "in": "path", + "required": true + } + ], + "responses": { + "200": {} + } + } + }, + "/repos/{owner}/{repo}/releases": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a release", + "operationId": "repoCreateRelease", + "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 + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateReleaseOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Release" + } + } + } + }, + "/repos/{owner}/{repo}/releases/{id}": { + "delete": { + "tags": [ + "repository" + ], + "summary": "Delete a release", + "operationId": "repoDeleteRelease", + "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 release to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Update a release", + "operationId": "repoEditRelease", + "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 release to edit", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditReleaseOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Release" + } + } + } + }, + "/repos/{owner}/{repo}/stargazers": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repo's stargazers", + "operationId": "repoListStargazers", + "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 + } + ], + "responses": { + "200": { + "$ref": "#/responses/UserList" + } + } + } + }, + "/repos/{owner}/{repo}/statuses/{sha}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a commit's statuses", + "operationId": "repoListStatuses", + "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": "string", + "description": "sha of the commit", + "name": "sha", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/StatusList" + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a commit status", + "operationId": "repoCreateStatus", + "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": "string", + "description": "sha of the commit", + "name": "sha", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateStatusOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/StatusList" + } + } + } + }, + "/repos/{owner}/{repo}/subscribers": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repo's watchers", + "operationId": "repoListSubscribers", + "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 + } + ], + "responses": { + "200": { + "$ref": "#/responses/UserList" + } + } + } + }, + "/repos/{owner}/{repo}/subscription": { + "get": { + "tags": [ + "repository" + ], + "summary": "Check if the current user is watching a repo", + "operationId": "userCurrentCheckSubscription", + "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 + } + ], + "responses": { + "200": { + "$ref": "#/responses/WatchInfo" + } + } + }, + "put": { + "tags": [ + "repository" + ], + "summary": "Watch a repo", + "operationId": "userCurrentPutSubscription", + "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 + } + ], + "responses": { + "200": { + "$ref": "#/responses/WatchInfo" + } + } + }, + "delete": { + "tags": [ + "repository" + ], + "summary": "Unwatch a repo", + "operationId": "userCurrentDeleteSubscription", + "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 + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + } + }, + "/repos/{owner}/{repo}/times": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repo's tracked times", + "operationId": "repoTrackedTimes", + "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 + } + ], + "responses": { + "200": { + "$ref": "#/responses/TrackedTimeList" + } + } + } + }, + "/repos/{owner}/{repo}/times/{tracker}": { "get": { "produces": [ "application/json" @@ -1541,19 +3483,77 @@ "tags": [ "user" ], + "summary": "List a user's tracked times in a repo", "operationId": "userTrackedTimes", + "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": "string", + "description": "username of user", + "name": "user", + "in": "path", + "required": true + } + ], "responses": { "200": { - "$ref": "#/responses/TrackedTimes" + "$ref": "#/responses/TrackedTimeList" + } + } + } + }, + "/repos/{user}/{repo}/hooks/{id}": { + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a hook in a repository", + "operationId": "repoDeleteHook", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true }, - "400": { - "$ref": "#/responses/error" + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "id of the hook to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" }, "404": { - "$ref": "#/responses/error" - }, - "500": { - "$ref": "#/responses/error" + "$ref": "#/responses/notFound" } } } @@ -1566,13 +3566,299 @@ "tags": [ "repository" ], + "summary": "Get a repository by id", "operationId": "repoGetByID", + "parameters": [ + { + "type": "integer", + "description": "id of the repo to get", + "name": "id", + "in": "path", + "required": true + } + ], "responses": { "200": { "$ref": "#/responses/Repository" + } + } + } + }, + "/teams/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Get a team", + "operationId": "orgGetTeam", + "parameters": [ + { + "type": "integer", + "description": "id of the team to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Team" + } + } + }, + "delete": { + "tags": [ + "organization" + ], + "summary": "Delete a team", + "operationId": "orgDeleteTeam", + "parameters": [ + { + "type": "integer", + "description": "id of the team to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "team deleted", + "schema": { + "$ref": "#/responses/empty" + } + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Edit a team", + "operationId": "orgEditTeam", + "parameters": [ + { + "type": "integer", + "description": "id of the team to edit", + "name": "id", + "in": "path", + "required": true }, - "500": { - "$ref": "#/responses/error" + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditTeamOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Team" + } + } + } + }, + "/teams/{id}/members": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List a team's members", + "operationId": "orgListTeamMembers", + "parameters": [ + { + "type": "integer", + "description": "id of the team", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/UserList" + } + } + } + }, + "/teams/{id}/members/{username}": { + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Add a team member", + "operationId": "orgAddTeamMember", + "parameters": [ + { + "type": "integer", + "description": "id of the team", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user to add", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Remove a team member", + "operationId": "orgAddTeamMember", + "parameters": [ + { + "type": "integer", + "description": "id of the team", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user to remove", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + } + }, + "/teams/{id}/repos": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List a team's repos", + "operationId": "orgListTeamRepos", + "parameters": [ + { + "type": "integer", + "description": "id of the team", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/RepositoryList" + } + } + } + }, + "/teams/{id}/repos/{org}/{repo}": { + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Add a repository to a team", + "operationId": "orgAddTeamMember", + "parameters": [ + { + "type": "integer", + "description": "id of the team", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "organization that owns the repo to add", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to add", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + }, + "delete": { + "description": "This does not delete the repository, it only removes the repository from the team.", + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Remove a repository from a team", + "operationId": "orgAddTeamMember", + "parameters": [ + { + "type": "integer", + "description": "id of the team", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "organization that owns the repo to remove", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to remove", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" } } } @@ -1585,6 +3871,7 @@ "tags": [ "user" ], + "summary": "Get the authenticated user", "operationId": "userGetCurrent", "responses": { "200": { @@ -1593,6 +3880,71 @@ } } }, + "/user/emails": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the authenticated user's email addresses", + "operationId": "userListEmails", + "responses": { + "200": { + "$ref": "#/responses/EmailList" + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Add email addresses", + "operationId": "userAddEmail", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateEmailOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/EmailList" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Delete email addresses", + "operationId": "userDeleteEmail", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/DeleteEmailOption" + } + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + } + }, "/user/followers": { "get": { "produces": [ @@ -1601,13 +3953,11 @@ "tags": [ "user" ], + "summary": "List the authenticated user's followers", "operationId": "userCurrentListFollowers", "responses": { "200": { "$ref": "#/responses/UserList" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -1620,23 +3970,31 @@ "tags": [ "user" ], + "summary": "List the users that the authenticated user is following", "operationId": "userCurrentListFollowing", "responses": { "200": { "$ref": "#/responses/UserList" - }, - "500": { - "$ref": "#/responses/error" } } } }, - "/user/following/{username}": { + "/user/following/{followee}": { "get": { "tags": [ "user" ], + "summary": "Check whether a user is followed by the authenticated user", "operationId": "userCurrentCheckFollowing", + "parameters": [ + { + "type": "string", + "description": "username of followed user", + "name": "followee", + "in": "path", + "required": true + } + ], "responses": { "204": { "$ref": "#/responses/empty" @@ -1645,18 +4003,27 @@ "$ref": "#/responses/notFound" } } - }, + } + }, + "/user/following/{username}": { "put": { "tags": [ "user" ], + "summary": "Follow a user", "operationId": "userCurrentPutFollow", + "parameters": [ + { + "type": "string", + "description": "username of user to follow", + "name": "username", + "in": "path", + "required": true + } + ], "responses": { "204": { "$ref": "#/responses/empty" - }, - "500": { - "$ref": "#/responses/error" } } }, @@ -1664,13 +4031,20 @@ "tags": [ "user" ], + "summary": "Unfollow a user", "operationId": "userCurrentDeleteFollow", + "parameters": [ + { + "type": "string", + "description": "username of user to unfollow", + "name": "username", + "in": "path", + "required": true + } + ], "responses": { "204": { "$ref": "#/responses/empty" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -1683,13 +4057,11 @@ "tags": [ "user" ], + "summary": "List the authenticated user's GPG keys", "operationId": "userCurrentListGPGKeys", "responses": { "200": { "$ref": "#/responses/GPGKeyList" - }, - "500": { - "$ref": "#/responses/error" } } }, @@ -1703,17 +4075,14 @@ "tags": [ "user" ], + "summary": "Create a GPG key", "operationId": "userCurrentPostGPGKey", "parameters": [ { - "uniqueItems": true, - "x-go-name": "ArmoredKey", - "description": "An armored GPG key to add", - "name": "armored_public_key", + "name": "Form", "in": "body", - "required": true, "schema": { - "type": "string" + "$ref": "#/definitions/CreateGPGKeyOption" } } ], @@ -1723,9 +4092,6 @@ }, "422": { "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -1738,16 +4104,23 @@ "tags": [ "user" ], + "summary": "Get a GPG key", "operationId": "userCurrentGetGPGKey", + "parameters": [ + { + "type": "integer", + "description": "id of key to get", + "name": "id", + "in": "path", + "required": true + } + ], "responses": { "200": { "$ref": "#/responses/GPGKey" }, "404": { "$ref": "#/responses/notFound" - }, - "500": { - "$ref": "#/responses/error" } } }, @@ -1758,16 +4131,23 @@ "tags": [ "user" ], + "summary": "Remove a GPG key", "operationId": "userCurrentDeleteGPGKey", + "parameters": [ + { + "type": "integer", + "description": "id of key to delete", + "name": "id", + "in": "path", + "required": true + } + ], "responses": { "204": { "$ref": "#/responses/empty" }, "403": { "$ref": "#/responses/forbidden" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -1780,13 +4160,11 @@ "tags": [ "user" ], + "summary": "List the authenticated user's public keys", "operationId": "userCurrentListKeys", "responses": { "200": { "$ref": "#/responses/PublicKeyList" - }, - "500": { - "$ref": "#/responses/error" } } }, @@ -1800,28 +4178,14 @@ "tags": [ "user" ], + "summary": "Create a public key", "operationId": "userCurrentPostKey", "parameters": [ { - "uniqueItems": true, - "x-go-name": "Title", - "description": "Title of the key to add", - "name": "title", + "name": "body", "in": "body", - "required": true, "schema": { - "type": "string" - } - }, - { - "uniqueItems": true, - "x-go-name": "Key", - "description": "An armored SSH key to add", - "name": "key", - "in": "body", - "required": true, - "schema": { - "type": "string" + "$ref": "#/definitions/CreateKeyOption" } } ], @@ -1831,9 +4195,6 @@ }, "422": { "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -1846,16 +4207,23 @@ "tags": [ "user" ], + "summary": "Get a public key", "operationId": "userCurrentGetKey", + "parameters": [ + { + "type": "integer", + "description": "id of key to get", + "name": "id", + "in": "path", + "required": true + } + ], "responses": { "200": { "$ref": "#/responses/PublicKey" }, "404": { "$ref": "#/responses/notFound" - }, - "500": { - "$ref": "#/responses/error" } } }, @@ -1866,16 +4234,40 @@ "tags": [ "user" ], + "summary": "Delete a public key", "operationId": "userCurrentDeleteKey", + "parameters": [ + { + "type": "integer", + "description": "id of key to delete", + "name": "id", + "in": "path", + "required": true + } + ], "responses": { "204": { "$ref": "#/responses/empty" }, "403": { "$ref": "#/responses/forbidden" - }, - "500": { - "$ref": "#/responses/error" + } + } + } + }, + "/user/orgs": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List the current user's organizations", + "operationId": "orgListCurrentUserOrgs", + "responses": { + "200": { + "$ref": "#/responses/OrganizationList" } } } @@ -1888,13 +4280,11 @@ "tags": [ "user" ], + "summary": "List the repos that the authenticated user owns or has access to", "operationId": "userCurrentListRepos", "responses": { "200": { "$ref": "#/responses/RepositoryList" - }, - "500": { - "$ref": "#/responses/error" } } }, @@ -1909,85 +4299,20 @@ "repository", "user" ], + "summary": "Create a repository", "operationId": "createCurrentUserRepo", "parameters": [ { - "uniqueItems": true, - "x-go-name": "Name", - "description": "Name of the repository to create", - "name": "name", + "name": "body", "in": "body", "schema": { - "type": "string" - } - }, - { - "x-go-name": "Description", - "description": "Description of the repository to create", - "name": "description", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Private", - "description": "Is the repository to create private ?", - "name": "private", - "in": "body", - "schema": { - "type": "boolean" - } - }, - { - "x-go-name": "AutoInit", - "description": "Init the repository to create ?", - "name": "auto_init", - "in": "body", - "schema": { - "type": "boolean" - } - }, - { - "x-go-name": "Gitignores", - "description": "Gitignores to use", - "name": "gitignores", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "License", - "description": "License to use", - "name": "license", - "in": "body", - "schema": { - "type": "string" - } - }, - { - "x-go-name": "Readme", - "description": "Readme of the repository to create", - "name": "readme", - "in": "body", - "schema": { - "type": "string" + "$ref": "#/definitions/CreateRepoOption" } } ], "responses": { "201": { "$ref": "#/responses/Repository" - }, - "403": { - "$ref": "#/responses/forbidden" - }, - "422": { - "$ref": "#/responses/validationError" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -2000,23 +4325,38 @@ "tags": [ "user" ], + "summary": "The repos that the authenticated user has starred", "operationId": "userCurrentListStarred", "responses": { "200": { "$ref": "#/responses/RepositoryList" - }, - "500": { - "$ref": "#/responses/error" } } } }, - "/user/starred/{username}/{reponame}": { + "/user/starred/{owner}/{repo}": { "get": { "tags": [ "user" ], + "summary": "Whether the authenticated is starring the repo", "operationId": "userCurrentCheckStarring", + "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 + } + ], "responses": { "204": { "$ref": "#/responses/empty" @@ -2030,13 +4370,27 @@ "tags": [ "user" ], + "summary": "Star the given repo", "operationId": "userCurrentPutStar", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to star", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to star", + "name": "repo", + "in": "path", + "required": true + } + ], "responses": { "204": { "$ref": "#/responses/empty" - }, - "500": { - "$ref": "#/responses/error" } } }, @@ -2044,13 +4398,27 @@ "tags": [ "user" ], + "summary": "Unstar the given repo", "operationId": "userCurrentDeleteStar", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to unstar", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to unstar", + "name": "repo", + "in": "path", + "required": true + } + ], "responses": { "204": { "$ref": "#/responses/empty" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -2063,13 +4431,11 @@ "tags": [ "user" ], + "summary": "List repositories watched by the authenticated user", "operationId": "userCurrentListSubscriptions", "responses": { "200": { "$ref": "#/responses/RepositoryList" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -2082,32 +4448,36 @@ "tags": [ "user" ], - "operationId": "userTrackedTimes", + "summary": "List the current user's tracked times", + "operationId": "userCurrentTrackedTimes", "responses": { "200": { - "$ref": "#/responses/TrackedTimes" - }, - "500": { - "$ref": "#/responses/error" + "$ref": "#/responses/TrackedTimeList" } } } }, - "/users/:username/followers": { + "/user/{username}/orgs": { "get": { "produces": [ "application/json" ], "tags": [ - "user" + "organization" + ], + "summary": "List a user's organizations", + "operationId": "orgListUserOrgs", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "in": "path" + } ], - "operationId": "userListFollowers", "responses": { "200": { - "$ref": "#/responses/UserList" - }, - "500": { - "$ref": "#/responses/error" + "$ref": "#/responses/OrganizationList" } } } @@ -2120,13 +4490,58 @@ "tags": [ "user" ], + "summary": "Search for users", "operationId": "userSearch", + "parameters": [ + { + "type": "string", + "description": "keyword", + "name": "q", + "in": "query" + }, + { + "type": "integer", + "description": "maximum number of users to return", + "name": "limit", + "in": "query" + } + ], "responses": { "200": { "$ref": "#/responses/UserList" + } + } + } + }, + "/users/{follower}/following/{followee}": { + "get": { + "tags": [ + "user" + ], + "summary": "Check if one user is following another user", + "operationId": "userCheckFollowing", + "parameters": [ + { + "type": "string", + "description": "username of following user", + "name": "follower", + "in": "path", + "required": true }, - "500": { - "$ref": "#/responses/error" + { + "type": "string", + "description": "username of followed user", + "name": "followee", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" } } } @@ -2139,16 +4554,49 @@ "tags": [ "user" ], + "summary": "Get a user", "operationId": "userGet", + "parameters": [ + { + "type": "string", + "description": "username of user to get", + "name": "username", + "in": "path", + "required": true + } + ], "responses": { "200": { "$ref": "#/responses/User" }, "404": { "$ref": "#/responses/notFound" - }, - "500": { - "$ref": "#/responses/error" + } + } + } + }, + "/users/{username}/followers": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the given user's followers", + "operationId": "userListFollowers", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/UserList" } } } @@ -2161,29 +4609,20 @@ "tags": [ "user" ], + "summary": "List the users that the given user is following", "operationId": "userListFollowing", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "in": "path", + "required": true + } + ], "responses": { "200": { "$ref": "#/responses/UserList" - }, - "500": { - "$ref": "#/responses/error" - } - } - } - }, - "/users/{username}/following/:target": { - "get": { - "tags": [ - "user" - ], - "operationId": "userCheckFollowing", - "responses": { - "204": { - "$ref": "#/responses/empty" - }, - "404": { - "$ref": "#/responses/notFound" } } } @@ -2196,13 +4635,20 @@ "tags": [ "user" ], + "summary": "List the given user's GPG keys", "operationId": "userListGPGKeys", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "in": "path", + "required": true + } + ], "responses": { "200": { "$ref": "#/responses/GPGKeyList" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -2215,13 +4661,20 @@ "tags": [ "user" ], + "summary": "List the given user's public keys", "operationId": "userListKeys", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "in": "path", + "required": true + } + ], "responses": { "200": { "$ref": "#/responses/PublicKeyList" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -2234,13 +4687,20 @@ "tags": [ "user" ], + "summary": "List the repos owned by the given user", "operationId": "userListRepos", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "in": "path", + "required": true + } + ], "responses": { "200": { "$ref": "#/responses/RepositoryList" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -2253,13 +4713,20 @@ "tags": [ "user" ], + "summary": "The repos that the given user has starred", "operationId": "userListStarred", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "in": "path", + "required": true + } + ], "responses": { "200": { "$ref": "#/responses/RepositoryList" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -2272,13 +4739,19 @@ "tags": [ "user" ], + "summary": "List the repositories watched by a user", "operationId": "userListSubscriptions", + "parameters": [ + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path" + } + ], "responses": { "200": { "$ref": "#/responses/RepositoryList" - }, - "500": { - "$ref": "#/responses/error" } } } @@ -2291,27 +4764,50 @@ "tags": [ "user" ], + "summary": "List the authenticated user's access tokens", "operationId": "userGetTokens", "responses": { "200": { "$ref": "#/responses/AccessTokenList" - }, - "500": { - "$ref": "#/responses/error" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Create an access token", + "operationId": "userCreateToken", + "parameters": [ + { + "type": "string", + "x-go-name": "Name", + "name": "name", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/AccessToken" } } } }, "/version": { "get": { - "description": "This show current running Gitea application version.", "produces": [ "application/json" ], "tags": [ "miscellaneous" ], - "summary": "Return Gitea running version.", + "summary": "Returns the version of the Gitea application", "operationId": "getVersion", "responses": { "200": { @@ -2322,6 +4818,883 @@ } }, "definitions": { + "AddCollaboratorOption": { + "description": "AddCollaboratorOption options when adding a user as a collaborator of a repository", + "type": "object", + "properties": { + "permission": { + "type": "string", + "x-go-name": "Permission" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "AddTimeOption": { + "description": "AddTimeOption options for adding time to an issue", + "type": "object", + "required": [ + "time" + ], + "properties": { + "time": { + "description": "time in seconds", + "type": "integer", + "format": "int64", + "x-go-name": "Time" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "Branch": { + "description": "Branch represents a repository branch", + "type": "object", + "properties": { + "commit": { + "$ref": "#/definitions/PayloadCommit" + }, + "name": { + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "Comment": { + "description": "Comment represents a comment on a commit or issue", + "type": "object", + "properties": { + "body": { + "type": "string", + "x-go-name": "Body" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "issue_url": { + "type": "string", + "x-go-name": "IssueURL" + }, + "pull_request_url": { + "type": "string", + "x-go-name": "PRURL" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "user": { + "$ref": "#/definitions/User" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateEmailOption": { + "description": "CreateEmailOption options when creating email addresses", + "type": "object", + "properties": { + "emails": { + "description": "email addresses to add", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Emails" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateForkOption": { + "description": "CreateForkOption options for creating a fork", + "type": "object", + "properties": { + "organization": { + "description": "organization name, if forking into an organization", + "type": "string", + "x-go-name": "Organization" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateGPGKeyOption": { + "description": "CreateGPGKeyOption options create user GPG key", + "type": "object", + "required": [ + "armored_public_key" + ], + "properties": { + "armored_public_key": { + "description": "An armored GPG key to add", + "type": "string", + "uniqueItems": true, + "x-go-name": "ArmoredKey" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateHookOption": { + "description": "CreateHookOption options when create a hook", + "type": "object", + "required": [ + "type", + "config" + ], + "properties": { + "active": { + "type": "boolean", + "default": false, + "x-go-name": "Active" + }, + "config": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Config" + }, + "events": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Events" + }, + "type": { + "type": "string", + "enum": [ + "gitea", + "gogs", + "slack", + "discord" + ], + "x-go-name": "Type" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateIssueCommentOption": { + "description": "CreateIssueCommentOption options for creating a comment on an issue", + "type": "object", + "required": [ + "body" + ], + "properties": { + "body": { + "type": "string", + "x-go-name": "Body" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateIssueOption": { + "description": "CreateIssueOption options to create one issue", + "type": "object", + "required": [ + "title" + ], + "properties": { + "assignee": { + "description": "username of assignee", + "type": "string", + "x-go-name": "Assignee" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "closed": { + "type": "boolean", + "x-go-name": "Closed" + }, + "labels": { + "description": "list of label ids", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + }, + "x-go-name": "Labels" + }, + "milestone": { + "description": "milestone id", + "type": "integer", + "format": "int64", + "x-go-name": "Milestone" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateKeyOption": { + "description": "CreateKeyOption options when creating a key", + "type": "object", + "required": [ + "title", + "key" + ], + "properties": { + "key": { + "description": "An armored SSH key to add", + "type": "string", + "uniqueItems": true, + "x-go-name": "Key" + }, + "title": { + "description": "Title of the key to add", + "type": "string", + "uniqueItems": true, + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateLabelOption": { + "description": "CreateLabelOption options for creating a label", + "type": "object", + "required": [ + "name", + "color" + ], + "properties": { + "color": { + "type": "string", + "x-go-name": "Color", + "example": "#00aabb" + }, + "name": { + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateMilestoneOption": { + "description": "CreateMilestoneOption options for creating a milestone", + "type": "object", + "properties": { + "description": { + "type": "string", + "x-go-name": "Description" + }, + "due_on": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateOrgOption": { + "description": "CreateOrgOption options for creating an organization", + "type": "object", + "required": [ + "username" + ], + "properties": { + "description": { + "type": "string", + "x-go-name": "Description" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "location": { + "type": "string", + "x-go-name": "Location" + }, + "username": { + "type": "string", + "x-go-name": "UserName" + }, + "website": { + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreatePullRequestOption": { + "description": "CreatePullRequestOption options when creating a pull request", + "type": "object", + "properties": { + "assignee": { + "type": "string", + "x-go-name": "Assignee" + }, + "base": { + "type": "string", + "x-go-name": "Base" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "head": { + "type": "string", + "x-go-name": "Head" + }, + "labels": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + }, + "x-go-name": "Labels" + }, + "milestone": { + "type": "integer", + "format": "int64", + "x-go-name": "Milestone" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateReleaseOption": { + "description": "CreateReleaseOption options when creating a release", + "type": "object", + "required": [ + "tag_name" + ], + "properties": { + "body": { + "type": "string", + "x-go-name": "Note" + }, + "draft": { + "type": "boolean", + "x-go-name": "IsDraft" + }, + "name": { + "type": "string", + "x-go-name": "Title" + }, + "prerelease": { + "type": "boolean", + "x-go-name": "IsPrerelease" + }, + "tag_name": { + "type": "string", + "x-go-name": "TagName" + }, + "target_commitish": { + "type": "string", + "x-go-name": "Target" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateRepoOption": { + "description": "CreateRepoOption options when creating repository", + "type": "object", + "required": [ + "name" + ], + "properties": { + "auto_init": { + "description": "Whether the repository should be auto-intialized?", + "type": "boolean", + "x-go-name": "AutoInit" + }, + "description": { + "description": "Description of the repository to create", + "type": "string", + "x-go-name": "Description" + }, + "gitignores": { + "description": "Gitignores to use", + "type": "string", + "x-go-name": "Gitignores" + }, + "license": { + "description": "License to use", + "type": "string", + "x-go-name": "License" + }, + "name": { + "description": "Name of the repository to create", + "type": "string", + "uniqueItems": true, + "x-go-name": "Name" + }, + "private": { + "description": "Whether the repository is private", + "type": "boolean", + "x-go-name": "Private" + }, + "readme": { + "description": "Readme of the repository to create", + "type": "string", + "x-go-name": "Readme" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateStatusOption": { + "description": "CreateStatusOption holds the information needed to create a new Status for a Commit", + "type": "object", + "properties": { + "context": { + "type": "string", + "x-go-name": "Context" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "state": { + "$ref": "#/definitions/StatusState" + }, + "target_url": { + "type": "string", + "x-go-name": "TargetURL" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateTeamOption": { + "description": "CreateTeamOption options for creating a team", + "type": "object", + "required": [ + "name" + ], + "properties": { + "description": { + "type": "string", + "x-go-name": "Description" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "permission": { + "type": "string", + "enum": [ + "read", + "write", + "admin" + ], + "x-go-name": "Permission" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "CreateUserOption": { + "description": "CreateUserOption create user options", + "type": "object", + "required": [ + "username", + "email", + "password" + ], + "properties": { + "email": { + "type": "string", + "format": "email", + "x-go-name": "Email" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "login_name": { + "type": "string", + "x-go-name": "LoginName" + }, + "password": { + "type": "string", + "x-go-name": "Password" + }, + "send_notify": { + "type": "boolean", + "x-go-name": "SendNotify" + }, + "source_id": { + "type": "integer", + "format": "int64", + "x-go-name": "SourceID" + }, + "username": { + "type": "string", + "x-go-name": "Username" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "DeleteEmailOption": { + "description": "DeleteEmailOption options when deleting email addresses", + "type": "object", + "properties": { + "emails": { + "description": "email addresses to delete", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Emails" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "DeployKey": { + "description": "DeployKey a deploy key", + "type": "object", + "properties": { + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "key": { + "type": "string", + "x-go-name": "Key" + }, + "read_only": { + "type": "boolean", + "x-go-name": "ReadOnly" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "EditHookOption": { + "description": "EditHookOption options when modify one hook", + "type": "object", + "properties": { + "active": { + "type": "boolean", + "x-go-name": "Active" + }, + "config": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Config" + }, + "events": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Events" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "EditIssueCommentOption": { + "description": "EditIssueCommentOption options for editing a comment", + "type": "object", + "required": [ + "body" + ], + "properties": { + "body": { + "type": "string", + "x-go-name": "Body" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "EditIssueOption": { + "description": "EditIssueOption options for editing an issue", + "type": "object", + "properties": { + "assignee": { + "type": "string", + "x-go-name": "Assignee" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "milestone": { + "type": "integer", + "format": "int64", + "x-go-name": "Milestone" + }, + "state": { + "type": "string", + "x-go-name": "State" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "EditLabelOption": { + "description": "EditLabelOption options for editing a label", + "type": "object", + "properties": { + "color": { + "type": "string", + "x-go-name": "Color" + }, + "name": { + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "EditMilestoneOption": { + "description": "EditMilestoneOption options for editing a milestone", + "type": "object", + "properties": { + "description": { + "type": "string", + "x-go-name": "Description" + }, + "due_on": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + }, + "state": { + "type": "string", + "x-go-name": "State" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "EditOrgOption": { + "description": "EditOrgOption options for editing an organization", + "type": "object", + "properties": { + "description": { + "type": "string", + "x-go-name": "Description" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "location": { + "type": "string", + "x-go-name": "Location" + }, + "website": { + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "EditPullRequestOption": { + "description": "EditPullRequestOption options when modify pull request", + "type": "object", + "properties": { + "assignee": { + "type": "string", + "x-go-name": "Assignee" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "labels": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + }, + "x-go-name": "Labels" + }, + "milestone": { + "type": "integer", + "format": "int64", + "x-go-name": "Milestone" + }, + "state": { + "type": "string", + "x-go-name": "State" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "EditReleaseOption": { + "description": "EditReleaseOption options when editing a release", + "type": "object", + "properties": { + "body": { + "type": "string", + "x-go-name": "Note" + }, + "draft": { + "type": "boolean", + "x-go-name": "IsDraft" + }, + "name": { + "type": "string", + "x-go-name": "Title" + }, + "prerelease": { + "type": "boolean", + "x-go-name": "IsPrerelease" + }, + "tag_name": { + "type": "string", + "x-go-name": "TagName" + }, + "target_commitish": { + "type": "string", + "x-go-name": "Target" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "EditTeamOption": { + "description": "EditTeamOption options for editing a team", + "type": "object", + "required": [ + "name" + ], + "properties": { + "description": { + "type": "string", + "x-go-name": "Description" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "permission": { + "type": "string", + "enum": [ + "read", + "write", + "admin" + ], + "x-go-name": "Permission" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "EditUserOption": { + "description": "EditUserOption edit user options", + "type": "object", + "required": [ + "email" + ], + "properties": { + "active": { + "type": "boolean", + "x-go-name": "Active" + }, + "admin": { + "type": "boolean", + "x-go-name": "Admin" + }, + "allow_git_hook": { + "type": "boolean", + "x-go-name": "AllowGitHook" + }, + "allow_import_local": { + "type": "boolean", + "x-go-name": "AllowImportLocal" + }, + "email": { + "type": "string", + "format": "email", + "x-go-name": "Email" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "location": { + "type": "string", + "x-go-name": "Location" + }, + "login_name": { + "type": "string", + "x-go-name": "LoginName" + }, + "max_repo_creation": { + "type": "integer", + "format": "int64", + "x-go-name": "MaxRepoCreation" + }, + "password": { + "type": "string", + "x-go-name": "Password" + }, + "source_id": { + "type": "integer", + "format": "int64", + "x-go-name": "SourceID" + }, + "website": { + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "Email": { + "description": "Email an email address belonging to a user", + "type": "object", + "properties": { + "email": { + "type": "string", + "format": "email", + "x-go-name": "Email" + }, + "primary": { + "type": "boolean", + "x-go-name": "Primary" + }, + "verified": { + "type": "boolean", + "x-go-name": "Verified" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, "GPGKey": { "description": "GPGKey a user GPG key to sign commit and tag in repository", "type": "object", @@ -2343,6 +5716,8 @@ "x-go-name": "CanSign" }, "created_at": { + "type": "string", + "format": "date-time", "x-go-name": "Created" }, "emails": { @@ -2353,6 +5728,8 @@ "x-go-name": "Emails" }, "expires_at": { + "type": "string", + "format": "date-time", "x-go-name": "Expires" }, "id": { @@ -2375,7 +5752,7 @@ "subkeys": { "type": "array", "items": { - "type": "object" + "$ref": "#/definitions/GPGKey" }, "x-go-name": "SubsKey" } @@ -2397,9 +5774,368 @@ }, "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" }, - "Permission": { + "Issue": { + "description": "Issue represents an issue in a repository", + "type": "object", + "properties": { + "assignee": { + "$ref": "#/definitions/User" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "comments": { + "type": "integer", + "format": "int64", + "x-go-name": "Comments" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/Label" + }, + "x-go-name": "Labels" + }, + "milestone": { + "$ref": "#/definitions/Milestone" + }, + "number": { + "type": "integer", + "format": "int64", + "x-go-name": "Index" + }, + "pull_request": { + "$ref": "#/definitions/PullRequestMeta" + }, + "state": { + "$ref": "#/definitions/StateType" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "user": { + "$ref": "#/definitions/User" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "IssueLabelsOption": { + "description": "IssueLabelsOption a collection of labels", + "type": "object", + "properties": { + "labels": { + "description": "list of label IDs", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + }, + "x-go-name": "Labels" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "Label": { + "description": "Label a label to an issue or a pr", + "type": "object", + "properties": { + "color": { + "type": "string", + "x-go-name": "Color", + "example": "00aabb" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "MarkdownOption": { + "description": "MarkdownOption markdown options", + "type": "object", + "properties": { + "Context": { + "description": "Context to render\n\nin: body", + "type": "string" + }, + "Mode": { + "description": "Mode to render\n\nin: body", + "type": "string" + }, + "Text": { + "description": "Text markdown to render\n\nin: body", + "type": "string" + }, + "Wiki": { + "description": "Is it a wiki page ?\n\nin: body", + "type": "boolean" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "MigrateRepoForm": { + "description": "MigrateRepoForm form for migrating repository", + "type": "object", + "required": [ + "clone_addr", + "uid", + "repo_name" + ], + "properties": { + "auth_password": { + "type": "string", + "x-go-name": "AuthPassword" + }, + "auth_username": { + "type": "string", + "x-go-name": "AuthUsername" + }, + "clone_addr": { + "type": "string", + "x-go-name": "CloneAddr" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "mirror": { + "type": "boolean", + "x-go-name": "Mirror" + }, + "private": { + "type": "boolean", + "x-go-name": "Private" + }, + "repo_name": { + "type": "string", + "x-go-name": "RepoName" + }, + "uid": { + "type": "integer", + "format": "int64", + "x-go-name": "UID" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/auth" + }, + "Milestone": { + "description": "Milestone milestone is a collection of issues on one repository", + "type": "object", + "properties": { + "closed_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Closed" + }, + "closed_issues": { + "type": "integer", + "format": "int64", + "x-go-name": "ClosedIssues" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "due_on": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "open_issues": { + "type": "integer", + "format": "int64", + "x-go-name": "OpenIssues" + }, + "state": { + "$ref": "#/definitions/StateType" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "Organization": { + "description": "Organization represents an organization", + "type": "object", + "properties": { + "avatar_url": { + "type": "string", + "x-go-name": "AvatarURL" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "location": { + "type": "string", + "x-go-name": "Location" + }, + "username": { + "type": "string", + "x-go-name": "UserName" + }, + "website": { + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "PRBranchInfo": { + "description": "PRBranchInfo information about a branch", + "type": "object", + "properties": { + "label": { + "type": "string", + "x-go-name": "Name" + }, + "ref": { + "type": "string", + "x-go-name": "Ref" + }, + "repo": { + "$ref": "#/definitions/Repository" + }, + "repo_id": { + "type": "integer", + "format": "int64", + "x-go-name": "RepoID" + }, + "sha": { + "type": "string", + "x-go-name": "Sha" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "PayloadCommit": { + "description": "PayloadCommit represents a commit", + "type": "object", + "properties": { + "author": { + "$ref": "#/definitions/PayloadUser" + }, + "committer": { + "$ref": "#/definitions/PayloadUser" + }, + "id": { + "description": "sha1 hash of the commit", + "type": "string", + "x-go-name": "ID" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "timestamp": { + "type": "string", + "format": "date-time", + "x-go-name": "Timestamp" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "verification": { + "$ref": "#/definitions/PayloadCommitVerification" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "PayloadCommitVerification": { + "description": "PayloadCommitVerification represents the GPG verification of a commit", + "type": "object", + "properties": { + "payload": { + "type": "string", + "x-go-name": "Payload" + }, + "reason": { + "type": "string", + "x-go-name": "Reason" + }, + "signature": { + "type": "string", + "x-go-name": "Signature" + }, + "verified": { + "type": "boolean", + "x-go-name": "Verified" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "PayloadUser": { + "description": "PayloadUser represents the author or committer of a commit", + "type": "object", + "properties": { + "email": { + "type": "string", + "format": "email", + "x-go-name": "Email" + }, + "name": { + "description": "Full name of the commit author", + "type": "string", + "x-go-name": "Name" + }, + "username": { + "type": "string", + "x-go-name": "UserName" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "Permission": { + "description": "Permission represents a set of permissions", "type": "object", - "title": "Permission represents a API permission.", "properties": { "admin": { "type": "boolean", @@ -2416,15 +6152,228 @@ }, "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" }, - "Repository": { + "PublicKey": { + "description": "PublicKey publickey is a user key to push code to repository", + "type": "object", + "properties": { + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "key": { + "type": "string", + "x-go-name": "Key" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "PullRequest": { + "description": "PullRequest represents a pull request", + "type": "object", + "properties": { + "assignee": { + "$ref": "#/definitions/User" + }, + "base": { + "$ref": "#/definitions/PRBranchInfo" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "comments": { + "type": "integer", + "format": "int64", + "x-go-name": "Comments" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "diff_url": { + "type": "string", + "x-go-name": "DiffURL" + }, + "head": { + "$ref": "#/definitions/PRBranchInfo" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/Label" + }, + "x-go-name": "Labels" + }, + "merge_base": { + "type": "string", + "x-go-name": "MergeBase" + }, + "merge_commit_sha": { + "type": "string", + "x-go-name": "MergedCommitID" + }, + "mergeable": { + "type": "boolean", + "x-go-name": "Mergeable" + }, + "merged": { + "type": "boolean", + "x-go-name": "HasMerged" + }, + "merged_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Merged" + }, + "merged_by": { + "$ref": "#/definitions/User" + }, + "milestone": { + "$ref": "#/definitions/Milestone" + }, + "number": { + "type": "integer", + "format": "int64", + "x-go-name": "Index" + }, + "patch_url": { + "type": "string", + "x-go-name": "PatchURL" + }, + "state": { + "$ref": "#/definitions/StateType" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "user": { + "$ref": "#/definitions/User" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "PullRequestMeta": { + "description": "PullRequestMeta PR info if an issue is a PR", + "type": "object", + "properties": { + "merged": { + "type": "boolean", + "x-go-name": "HasMerged" + }, + "merged_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Merged" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "Release": { + "description": "Release represents a repository release", + "type": "object", + "properties": { + "author": { + "$ref": "#/definitions/User" + }, + "body": { + "type": "string", + "x-go-name": "Note" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "CreatedAt" + }, + "draft": { + "type": "boolean", + "x-go-name": "IsDraft" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Title" + }, + "prerelease": { + "type": "boolean", + "x-go-name": "IsPrerelease" + }, + "published_at": { + "type": "string", + "format": "date-time", + "x-go-name": "PublishedAt" + }, + "tag_name": { + "type": "string", + "x-go-name": "TagName" + }, + "tarball_url": { + "type": "string", + "x-go-name": "TarURL" + }, + "target_commitish": { + "type": "string", + "x-go-name": "Target" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "zipball_url": { + "type": "string", + "x-go-name": "ZipURL" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "Repository": { + "description": "Repository represents a repository", "type": "object", - "title": "Repository represents a API repository.", "properties": { "clone_url": { "type": "string", "x-go-name": "CloneURL" }, "created_at": { + "type": "string", + "format": "date-time", "x-go-name": "Created" }, "default_branch": { @@ -2478,7 +6427,7 @@ "$ref": "#/definitions/User" }, "parent": { - "type": "object" + "$ref": "#/definitions/Repository" }, "permissions": { "$ref": "#/definitions/Permission" @@ -2502,6 +6451,8 @@ "x-go-name": "Stars" }, "updated_at": { + "type": "string", + "format": "date-time", "x-go-name": "Updated" }, "watchers_count": { @@ -2516,33 +6467,217 @@ }, "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" }, - "User": { + "SearchResults": { + "description": "SearchResults results of a successful search", "type": "object", - "title": "User represents a API user.", "properties": { - "avatar_url": { - "type": "string", - "x-go-name": "AvatarURL" + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/Repository" + }, + "x-go-name": "Data" }, - "email": { + "ok": { + "type": "boolean", + "x-go-name": "OK" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "ServerVersion": { + "description": "ServerVersion wraps the version of the server", + "type": "object", + "properties": { + "version": { "type": "string", - "x-go-name": "Email" + "x-go-name": "Version" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "StateType": { + "description": "StateType issue state type", + "type": "string", + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "Status": { + "description": "Status holds a single Status of a single Commit", + "type": "object", + "properties": { + "context": { + "type": "string", + "x-go-name": "Context" }, - "full_name": { + "created_at": { "type": "string", - "x-go-name": "FullName" + "format": "date-time", + "x-go-name": "Created" + }, + "creator": { + "$ref": "#/definitions/User" + }, + "description": { + "type": "string", + "x-go-name": "Description" }, "id": { "type": "integer", "format": "int64", "x-go-name": "ID" }, + "status": { + "$ref": "#/definitions/StatusState" + }, + "target_url": { + "type": "string", + "x-go-name": "TargetURL" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "StatusState": { + "description": "StatusState holds the state of a Status\nIt can be \"pending\", \"success\", \"error\", \"failure\", and \"warning\"", + "type": "string", + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "Team": { + "description": "Team represents a team in an organization", + "type": "object", + "properties": { + "description": { + "type": "string", + "x-go-name": "Description" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "permission": { + "type": "string", + "enum": [ + "none", + "read", + "write", + "admin", + "owner" + ], + "x-go-name": "Permission" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "TrackedTime": { + "description": "TrackedTime worked time for an issue / pr", + "type": "object", + "properties": { + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "issue_id": { + "type": "integer", + "format": "int64", + "x-go-name": "IssueID" + }, + "time": { + "description": "Time in seconds", + "type": "integer", + "format": "int64", + "x-go-name": "Time" + }, + "user_id": { + "type": "integer", + "format": "int64", + "x-go-name": "UserID" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "User": { + "description": "User represents a user", + "type": "object", + "properties": { + "avatar_url": { + "description": "URL to the user's avatar", + "type": "string", + "x-go-name": "AvatarURL" + }, + "email": { + "type": "string", + "format": "email", + "x-go-name": "Email" + }, + "full_name": { + "description": "the user's full name", + "type": "string", + "x-go-name": "FullName" + }, + "id": { + "description": "the user's id", + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, "login": { + "description": "the user's username", "type": "string", "x-go-name": "UserName" } }, "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + }, + "WatchInfo": { + "description": "WatchInfo represents an API watch status of one repository", + "type": "object", + "properties": { + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "CreatedAt" + }, + "ignored": { + "type": "boolean", + "x-go-name": "Ignored" + }, + "reason": { + "type": "object", + "x-go-name": "Reason" + }, + "repository_url": { + "type": "string", + "x-go-name": "RepositoryURL" + }, + "subscribed": { + "type": "boolean", + "x-go-name": "Subscribed" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" } }, "responses": { @@ -2560,317 +6695,257 @@ "AccessTokenList": { "description": "AccessTokenList represents a list of API access token." }, - "GPGKey": { - "description": "GPGKey a user GPG key to sign commit and tag in repository", - "headers": { - "can_certify": { - "type": "boolean" - }, - "can_encrypt_comms": { - "type": "boolean" - }, - "can_encrypt_storage": { - "type": "boolean" - }, - "can_sign": { - "type": "boolean" - }, - "created_at": {}, - "emails": { - "type": "array", - "items": { - "$ref": "#/definitions/GPGKeyEmail" - } - }, - "expires_at": {}, - "id": { - "type": "integer", - "format": "int64" - }, - "key_id": { - "type": "string" - }, - "primary_key_id": { - "type": "string" - }, - "public_key": { - "type": "string" - }, - "subkeys": { - "type": "array", - "items": { - "type": "object" - } + "Branch": { + "schema": { + "$ref": "#/definitions/Branch" + } + }, + "BranchList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Branch" } } }, + "Comment": { + "schema": { + "$ref": "#/definitions/Comment" + } + }, + "CommentList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Comment" + } + } + }, + "DeployKey": { + "schema": { + "$ref": "#/definitions/DeployKey" + } + }, + "DeployKeyList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/DeployKey" + } + } + }, + "EmailList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Email" + } + } + }, + "GPGKey": { + "schema": { + "$ref": "#/definitions/GPGKey" + } + }, "GPGKeyList": { - "description": "GPGKeyList represents a list of GPGKey" + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/GPGKey" + } + } }, "Hook": { - "description": "Hook a hook is a web hook when one repository changed", "schema": { - "type": "object", - "additionalProperties": { - "type": "string" + "type": "array", + "items": { + "$ref": "#/definitions/Branch" } - }, - "headers": { - "active": { - "type": "boolean" - }, - "config": {}, - "created_at": {}, - "events": { - "type": "array", - "items": { - "type": "string" - } - }, - "id": { - "type": "integer", - "format": "int64" - }, - "type": { - "type": "string" - }, - "updated_at": {} } }, "HookList": { - "description": "HookList represents a list of API hook." + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Branch" + } + } + }, + "Issue": { + "schema": { + "$ref": "#/definitions/Issue" + } + }, + "IssueList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Issue" + } + } + }, + "Label": { + "schema": { + "$ref": "#/definitions/Label" + } + }, + "LabelList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Label" + } + } }, "MarkdownRender": { "description": "MarkdownRender is a rendered markdown document" }, + "Milestone": { + "schema": { + "$ref": "#/definitions/Milestone" + } + }, + "MilestoneList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Milestone" + } + } + }, "Organization": { - "description": "Organization a group of some repositories, users and teams", - "headers": { - "avatar_url": { - "type": "string" - }, - "description": { - "type": "string" - }, - "full_name": { - "type": "string" - }, - "id": { - "type": "integer", - "format": "int64" - }, - "location": { - "type": "string" - }, - "username": { - "type": "string" - }, - "website": { - "type": "string" + "schema": { + "$ref": "#/definitions/Organization" + } + }, + "OrganizationList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Organization" } } }, "PublicKey": { - "description": "PublicKey publickey is a user key to push code to repository", - "headers": { - "created_at": {}, - "id": { - "type": "integer", - "format": "int64" - }, - "key": { - "type": "string" - }, - "title": { - "type": "string" - }, - "url": { - "type": "string" - } + "schema": { + "$ref": "#/definitions/PublicKey" } }, "PublicKeyList": { - "description": "PublicKeyList represents a list of PublicKey" - }, - "Repository": { - "description": "Repository represents a API repository.", "schema": { - "$ref": "#/definitions/Permission" - }, - "headers": { - "clone_url": { - "type": "string" - }, - "created_at": {}, - "default_branch": { - "type": "string" - }, - "description": { - "type": "string" - }, - "empty": { - "type": "boolean" - }, - "fork": { - "type": "boolean" - }, - "forks_count": { - "type": "integer", - "format": "int64" - }, - "full_name": { - "type": "string" - }, - "html_url": { - "type": "string" - }, - "id": { - "type": "integer", - "format": "int64" - }, - "mirror": { - "type": "boolean" - }, - "name": { - "type": "string" - }, - "open_issues_count": { - "type": "integer", - "format": "int64" - }, - "owner": {}, - "parent": {}, - "permissions": {}, - "private": { - "type": "boolean" - }, - "size": { - "type": "integer", - "format": "int64" - }, - "ssh_url": { - "type": "string" - }, - "stars_count": { - "type": "integer", - "format": "int64" - }, - "updated_at": {}, - "watchers_count": { - "type": "integer", - "format": "int64" - }, - "website": { - "type": "string" + "type": "array", + "items": { + "$ref": "#/definitions/PublicKey" } } }, - "RepositoryList": { - "description": "RepositoryList represents a list of API repository." + "PullRequest": { + "schema": { + "$ref": "#/definitions/PullRequest" + } }, - "SearchError": { - "description": "SearchError error of failing search", - "headers": { - "error": { - "type": "string" - }, - "ok": { - "type": "boolean" + "PullRequestList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PullRequest" + } + } + }, + "Release": { + "schema": { + "$ref": "#/definitions/Release" + } + }, + "ReleaseList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Release" + } + } + }, + "Repository": { + "schema": { + "$ref": "#/definitions/Repository" + } + }, + "RepositoryList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Repository" } } }, "SearchResults": { - "description": "SearchResults results of search", + "schema": { + "$ref": "#/definitions/SearchResults" + }, "headers": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/Repository" - } - }, - "ok": { - "type": "boolean" - } + "body": {} } }, "ServerVersion": { - "description": "ServerVersion wraps the version of the server", - "headers": { - "Version": { - "type": "string" + "schema": { + "$ref": "#/definitions/ServerVersion" + } + }, + "Status": { + "schema": { + "$ref": "#/definitions/Status" + } + }, + "StatusList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Status" + } + } + }, + "Team": { + "schema": { + "$ref": "#/definitions/Team" + } + }, + "TeamList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Team" } } }, "TrackedTime": { - "description": "TrackedTime worked time for an issue / pr", - "headers": { - "created": {}, - "id": { - "type": "integer", - "format": "int64" - }, - "issue_id": { - "type": "integer", - "format": "int64" - }, - "time": { - "type": "integer", - "format": "int64", - "description": "Time in seconds" - }, - "user_id": { - "type": "integer", - "format": "int64" + "schema": { + "$ref": "#/definitions/TrackedTime" + } + }, + "TrackedTimeList": { + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/TrackedTime" } } }, - "TrackedTimes": { - "description": "TrackedTimes represent a list of tracked times" - }, "User": { - "description": "User represents a API user.", - "headers": { - "avatar_url": { - "type": "string" - }, - "email": { - "type": "string" - }, - "full_name": { - "type": "string" - }, - "id": { - "type": "integer", - "format": "int64" - }, - "login": { - "type": "string" - } + "schema": { + "$ref": "#/definitions/User" } }, "UserList": { - "description": "UserList represents a list of API user." + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + } + } }, "WatchInfo": { - "description": "WatchInfo represents a API watch status of one repository", "schema": { - "type": "object" - }, - "headers": { - "created_at": {}, - "ignored": { - "type": "boolean" - }, - "reason": {}, - "repository_url": { - "type": "string" - }, - "subscribed": { - "type": "boolean" - }, - "url": { - "type": "string" - } + "$ref": "#/definitions/WatchInfo" } }, "empty": { @@ -2901,6 +6976,44 @@ "notFound": { "description": "APINotFound is a not found empty response" }, + "parameterBodies": { + "schema": { + "$ref": "#/definitions/MigrateRepoForm" + }, + "headers": { + "AddCollaboratorOption": {}, + "AddTimeOption": {}, + "CreateEmailOption": {}, + "CreateForkOption": {}, + "CreateHookOption": {}, + "CreateIssueCommentOption": {}, + "CreateIssueOption": {}, + "CreateKeyOption": {}, + "CreateLabelOption": {}, + "CreateMilestoneOption": {}, + "CreateOrgOption": {}, + "CreatePullRequestOption": {}, + "CreateReleaseOption": {}, + "CreateRepoOption": {}, + "CreateStatusOption": {}, + "CreateTeamOption": {}, + "CreateUserOption": {}, + "DeleteEmailOption": {}, + "EditHookOption": {}, + "EditIssueCommentOption": {}, + "EditIssueOption": {}, + "EditLabelOption": {}, + "EditMilestoneOption": {}, + "EditOrgOption": {}, + "EditPullRequestOption": {}, + "EditReleaseOption": {}, + "EditTeamOption": {}, + "EditUserOption": {}, + "IssueLabelsOption": {}, + "MarkdownOption": {}, + "MigrateRepoForm": {} + } + }, "redirect": { "description": "APIRedirect is a redirect response" }, diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index 99c9cf0b95..d247b51c72 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -15,20 +15,26 @@ import ( // CreateOrg api for create organization func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) { - // swagger:route POST /admin/users/{username}/orgs admin adminCreateOrg - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 201: Organization - // 403: forbidden - // 422: validationError - // 500: error - + // swagger:operation POST /admin/users/{username}/orgs admin adminCreateOrg + // --- + // summary: Create an organization + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of the user that will own the created organization + // type: string + // required: true + // responses: + // "201": + // "$ref": "#/responses/Organization" + // "403": + // "$ref": "#/responses/forbidden" + // "422": + // "$ref": "#/responses/validationError" u := user.GetUserByParams(ctx) if ctx.Written() { return diff --git a/routers/api/v1/admin/repo.go b/routers/api/v1/admin/repo.go index 232fb988c8..70765557fb 100644 --- a/routers/api/v1/admin/repo.go +++ b/routers/api/v1/admin/repo.go @@ -14,20 +14,26 @@ import ( // CreateRepo api for creating a repository func CreateRepo(ctx *context.APIContext, form api.CreateRepoOption) { - // swagger:route POST /admin/users/{username}/repos admin adminCreateRepo - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 201: Repository - // 403: forbidden - // 422: validationError - // 500: error - + // swagger:operation POST /admin/users/{username}/repos admin adminCreateRepo + // --- + // summary: Create a repository on behalf a user + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of the user. This user will own the created repository + // type: string + // required: true + // responses: + // "201": + // "$ref": "#/responses/Repository" + // "403": + // "$ref": "#/responses/forbidden" + // "422": + // "$ref": "#/responses/validationError" owner := user.GetUserByParams(ctx) if ctx.Written() { return diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 74cbba8cde..19f24aed8f 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -5,13 +5,12 @@ package admin import ( - api "code.gitea.io/sdk/gitea" - "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers/api/v1/user" + api "code.gitea.io/sdk/gitea" ) func parseLoginSource(ctx *context.APIContext, u *models.User, sourceID int64, loginName string) { @@ -34,22 +33,27 @@ func parseLoginSource(ctx *context.APIContext, u *models.User, sourceID int64, l u.LoginName = loginName } -// CreateUser api for creating a user +// CreateUser create a user func CreateUser(ctx *context.APIContext, form api.CreateUserOption) { - // swagger:route POST /admin/users admin adminCreateUser - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 201: User - // 403: forbidden - // 422: validationError - // 500: error - + // swagger:operation POST /admin/users admin adminCreateUser + // --- + // summary: Create a user + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateUserOption" + // responses: + // "201": + // "$ref": "#/responses/User" + // "403": + // "$ref": "#/responses/forbidden" + // "422": + // "$ref": "#/responses/validationError" u := &models.User{ Name: form.Username, FullName: form.FullName, @@ -87,20 +91,30 @@ func CreateUser(ctx *context.APIContext, form api.CreateUserOption) { // EditUser api for modifying a user's information func EditUser(ctx *context.APIContext, form api.EditUserOption) { - // swagger:route PATCH /admin/users/{username} admin adminEditUser - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 200: User - // 403: forbidden - // 422: validationError - // 500: error - + // swagger:operation PATCH /admin/users/{username} admin adminEditUser + // --- + // summary: Edit an existing user + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of user to edit + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/EditUserOption" + // responses: + // "200": + // "$ref": "#/responses/User" + // "403": + // "$ref": "#/responses/forbidden" + // "422": + // "$ref": "#/responses/validationError" u := user.GetUserByParams(ctx) if ctx.Written() { return @@ -157,17 +171,24 @@ func EditUser(ctx *context.APIContext, form api.EditUserOption) { // DeleteUser api for deleting a user func DeleteUser(ctx *context.APIContext) { - // swagger:route DELETE /admin/users/{username} admin adminDeleteUser - // - // Produces: - // - application/json - // - // Responses: - // 204: empty - // 403: forbidden - // 422: validationError - // 500: error - + // swagger:operation DELETE /admin/users/{username} admin adminDeleteUser + // --- + // summary: Delete a user + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of user to delete + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" + // "403": + // "$ref": "#/responses/forbidden" + // "422": + // "$ref": "#/responses/validationError" u := user.GetUserByParams(ctx) if ctx.Written() { return @@ -189,20 +210,26 @@ func DeleteUser(ctx *context.APIContext) { // CreatePublicKey api for creating a public key to a user func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) { - // swagger:route POST /admin/users/{username}/keys admin adminCreatePublicKey - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 201: PublicKey - // 403: forbidden - // 422: validationError - // 500: error - + // swagger:operation POST /admin/users/{username}/keys admin adminCreatePublicKey + // --- + // summary: Add a public key on behalf of a user + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of the user + // type: string + // required: true + // responses: + // "201": + // "$ref": "#/responses/PublicKey" + // "403": + // "$ref": "#/responses/forbidden" + // "422": + // "$ref": "#/responses/validationError" u := user.GetUserByParams(ctx) if ctx.Written() { return diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 4331929614..b6e7df1215 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -4,11 +4,7 @@ // Package v1 Gitea API. // -// This provide API interface to communicate with this Gitea instance. -// -// Terms Of Service: -// -// there are no TOS at this moment, use at your own risk we take no responsibility +// This documentation describes the Gitea API. // // Schemes: http, https // BasePath: /api/v1 @@ -51,11 +47,6 @@ package v1 import ( "strings" - "github.com/go-macaron/binding" - "gopkg.in/macaron.v1" - - api "code.gitea.io/sdk/gitea" - "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/context" @@ -63,8 +54,13 @@ import ( "code.gitea.io/gitea/routers/api/v1/misc" "code.gitea.io/gitea/routers/api/v1/org" "code.gitea.io/gitea/routers/api/v1/repo" + _ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation "code.gitea.io/gitea/routers/api/v1/user" "code.gitea.io/gitea/routers/api/v1/utils" + api "code.gitea.io/sdk/gitea" + + "github.com/go-macaron/binding" + "gopkg.in/macaron.v1" ) func repoAssignment() macaron.Handler { @@ -320,7 +316,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("", user.GetAuthenticatedUser) m.Combo("/emails").Get(user.ListEmails). Post(bind(api.CreateEmailOption{}), user.AddEmail). - Delete(bind(api.CreateEmailOption{}), user.DeleteEmail) + Delete(bind(api.DeleteEmailOption{}), user.DeleteEmail) m.Get("/followers", user.ListMyFollowers) m.Group("/following", func() { @@ -435,7 +431,6 @@ func RegisterRoutes(m *macaron.Macaron) { m.Combo("").Get(repo.ListTrackedTimes). Post(reqToken(), bind(api.AddTimeOption{}), repo.AddTime) }) - }) }, mustEnableIssues) m.Group("/labels", func() { @@ -484,8 +479,8 @@ func RegisterRoutes(m *macaron.Macaron) { Post(reqToken(), reqRepoWriter(), bind(api.CreateStatusOption{}), repo.NewCommitStatus) }) m.Group("/commits/:ref", func() { - m.Get("/status", repo.GetCombinedCommitStatus) - m.Get("/statuses", repo.GetCommitStatuses) + m.Get("/status", repo.GetCombinedCommitStatusByRef) + m.Get("/statuses", repo.GetCommitStatusesByRef) }) }, repoAssignment()) }) diff --git a/routers/api/v1/misc/markdown.go b/routers/api/v1/misc/markdown.go index 8e3c66841f..ed50c1c05b 100644 --- a/routers/api/v1/misc/markdown.go +++ b/routers/api/v1/misc/markdown.go @@ -15,18 +15,23 @@ import ( // Markdown render markdown document to HTML func Markdown(ctx *context.APIContext, form api.MarkdownOption) { - // swagger:route POST /markdown miscellaneous renderMarkdown - // - // Consumes: - // - application/json - // - // Produces: + // swagger:operation POST /markdown miscellaneous renderMarkdown + // --- + // summary: Render a markdown document as HTML + // parameters: + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/MarkdownOption" + // consumes: + // - application/json + // produces: // - text/html - // - // Responses: - // 200: MarkdownRender - // 422: validationError - + // responses: + // "200": + // "$ref": "#/responses/MarkdownRender" + // "422": + // "$ref": "#/responses/validationError" if ctx.HasAPIError() { ctx.Error(422, "", ctx.GetErrMsg()) return @@ -53,17 +58,22 @@ func Markdown(ctx *context.APIContext, form api.MarkdownOption) { // MarkdownRaw render raw markdown HTML func MarkdownRaw(ctx *context.APIContext) { - // swagger:route POST /markdown/raw miscellaneous renderMarkdownRaw - // - // Consumes: + // swagger:operation POST /markdown/raw miscellaneous renderMarkdownRaw + // --- + // summary: Render raw markdown as HTML + // parameters: + // - name: body + // in: body + // type: string + // consumes: // - text/plain - // - // Produces: + // produces: // - text/html - // - // Responses: - // 200: MarkdownRender - // 422: validationError + // responses: + // "200": + // "$ref": "#/responses/MarkdownRender" + // "422": + // "$ref": "#/responses/validationError" body, err := ctx.Req.Body().Bytes() if err != nil { ctx.Error(422, "", err) diff --git a/routers/api/v1/misc/version.go b/routers/api/v1/misc/version.go index 1780398bf9..20e0a60c72 100644 --- a/routers/api/v1/misc/version.go +++ b/routers/api/v1/misc/version.go @@ -12,17 +12,13 @@ import ( // Version shows the version of the Gitea server func Version(ctx *context.APIContext) { - // swagger:route GET /version miscellaneous getVersion - // - // Return Gitea running version. - // - // This show current running Gitea application version. - // - // Produces: - // - application/json - // - // Responses: - // 200: ServerVersion - + // swagger:operation GET /version miscellaneous getVersion + // --- + // summary: Returns the version of the Gitea application + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/ServerVersion" ctx.JSON(200, &gitea.ServerVersion{Version: setting.AppVer}) } diff --git a/routers/api/v1/org/hook.go b/routers/api/v1/org/hook.go index d8a4c45fc8..0a77d795e6 100644 --- a/routers/api/v1/org/hook.go +++ b/routers/api/v1/org/hook.go @@ -15,15 +15,14 @@ import ( // ListHooks list an organziation's webhooks func ListHooks(ctx *context.APIContext) { - // swagger:route GET /orgs/{orgname}/hooks organization orgListHooks - // - // Produces: - // - application/json - // - // Responses: - // 200: HookList - // 500: error - + // swagger:operation GET /orgs/{org}/hooks organization orgListHooks + // --- + // summary: List an organization's webhooks + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/HookList" org := ctx.Org.Organization orgHooks, err := models.GetWebhooksByOrgID(org.ID) if err != nil { @@ -39,16 +38,14 @@ func ListHooks(ctx *context.APIContext) { // GetHook get an organization's hook by id func GetHook(ctx *context.APIContext) { - // swagger:route GET /orgs/{orgname}/hooks/{id} organization orgGetHook - // - // Produces: - // - application/json - // - // Responses: - // 200: Hook - // 404: notFound - // 500: error - + // swagger:operation GET /orgs/{org}/hooks/{id} organization orgGetHook + // --- + // summary: Get a hook + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/Hook" org := ctx.Org.Organization hookID := ctx.ParamsInt64(":id") hook, err := utils.GetOrgHook(ctx, org.ID, hookID) @@ -60,19 +57,16 @@ func GetHook(ctx *context.APIContext) { // CreateHook create a hook for an organization func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { - // swagger:route POST /orgs/{orgname}/hooks/ organization orgCreateHook - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 201: Hook - // 422: validationError - // 500: error - + // swagger:operation POST /orgs/{org}/hooks/ organization orgCreateHook + // --- + // summary: Create a hook + // consumes: + // - application/json + // produces: + // - application/json + // responses: + // "201": + // "$ref": "#/responses/Hook" if !utils.CheckCreateHookOption(ctx, &form) { return } @@ -81,36 +75,30 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { // EditHook modify a hook of a repository func EditHook(ctx *context.APIContext, form api.EditHookOption) { - // swagger:route PATCH /orgs/{orgname}/hooks/{id} organization orgEditHook - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 200: Hook - // 422: validationError - // 404: notFound - // 500: error - + // swagger:operation PATCH /orgs/{org}/hooks/{id} organization orgEditHook + // --- + // summary: Update a hook + // consumes: + // - application/json + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/Hook" hookID := ctx.ParamsInt64(":id") utils.EditOrgHook(ctx, &form, hookID) } // DeleteHook delete a hook of an organization func DeleteHook(ctx *context.APIContext) { - // swagger:route DELETE /orgs/{orgname}/hooks/{id} organization orgDeleteHook - // - // Produces: - // - application/json - // - // Responses: - // 204: empty - // 404: notFound - // 500: error - + // swagger:operation DELETE /orgs/{org}/hooks/{id} organization orgDeleteHook + // --- + // summary: Delete a hook + // produces: + // - application/json + // responses: + // "204": + // "$ref": "#/responses/empty" org := ctx.Org.Organization hookID := ctx.ParamsInt64(":id") if err := models.DeleteWebhookByOrgID(org.ID, hookID); err != nil { diff --git a/routers/api/v1/org/member.go b/routers/api/v1/org/member.go index 3495370556..7cae7c19fa 100644 --- a/routers/api/v1/org/member.go +++ b/routers/api/v1/org/member.go @@ -53,45 +53,68 @@ func listMembers(ctx *context.APIContext, publicOnly bool) { // ListMembers list an organization's members func ListMembers(ctx *context.APIContext) { - // swagger:route GET /orgs/{orgname}/members organization orgListMembers - // - // Produces: - // - application/json - // - // Responses: - // 200: UserList - // 500: error - + // swagger:operation GET /orgs/{org}/members organization orgListMembers + // --- + // summary: List an organization's members + // produces: + // - application/json + // parameters: + // - name: org + // in: path + // description: name of the organization + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/UserList" publicOnly := ctx.User == nil || !ctx.Org.Organization.IsOrgMember(ctx.User.ID) listMembers(ctx, publicOnly) } // ListPublicMembers list an organization's public members func ListPublicMembers(ctx *context.APIContext) { - // swagger:route GET /orgs/{orgname}/public_members organization orgListPublicMembers - // - // Produces: - // - application/json - // - // Responses: - // 200: UserList - // 500: error - + // swagger:operation GET /orgs/{org}/public_members organization orgListPublicMembers + // --- + // summary: List an organization's public members + // parameters: + // - name: org + // in: path + // description: name of the organization + // type: string + // required: true + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/UserList" listMembers(ctx, true) } // IsMember check if a user is a member of an organization func IsMember(ctx *context.APIContext) { - // swagger:route GET /orgs/{orgname}/members/{username} organization orgIsMember - // - // Produces: - // - application/json - // - // Responses: - // 204: empty - // 302: redirect - // 404: notFound - + // swagger:operation GET /orgs/{org}/members/{username} organization orgIsMember + // --- + // summary: Check if a user is a member of an organization + // parameters: + // - name: org + // in: path + // description: name of the organization + // type: string + // required: true + // - name: username + // in: path + // description: username of the user + // type: string + // required: true + // 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 @@ -113,15 +136,29 @@ func IsMember(ctx *context.APIContext) { // IsPublicMember check if a user is a public member of an organization func IsPublicMember(ctx *context.APIContext) { - // swagger:route GET /orgs/{orgname}/public_members/{username} organization orgIsPublicMember - // - // Produces: - // - application/json - // - // Responses: - // 204: empty - // 404: notFound - + // swagger:operation GET /orgs/{org}/public_members/{username} organization orgIsPublicMember + // --- + // summary: Check if a user is a public member of an organization + // parameters: + // - name: org + // in: path + // description: name of the organization + // type: string + // required: true + // - name: username + // in: path + // description: username of the user + // type: string + // required: true + // 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 @@ -135,16 +172,27 @@ func IsPublicMember(ctx *context.APIContext) { // PublicizeMember make a member's membership public func PublicizeMember(ctx *context.APIContext) { - // swagger:route PUT /orgs/{orgname}/public_members/{username} organization orgPublicizeMember - // - // Produces: - // - application/json - // - // Responses: - // 204: empty - // 403: forbidden - // 500: error - + // swagger:operation PUT /orgs/{org}/public_members/{username} organization orgPublicizeMember + // --- + // summary: Publicize a user's membership + // produces: + // - application/json + // parameters: + // - name: org + // in: path + // description: name of the organization + // type: string + // required: true + // - name: username + // in: path + // description: username of the user + // type: string + // required: true + // responses: + // "204": + // description: membership publicized + // schema: + // "$ref": "#/responses/empty" userToPublicize := user.GetUserByParams(ctx) if ctx.Written() { return @@ -163,16 +211,25 @@ func PublicizeMember(ctx *context.APIContext) { // ConcealMember make a member's membership not public func ConcealMember(ctx *context.APIContext) { - // swagger:route DELETE /orgs/{orgname}/public_members/{username} organization orgConcealMember - // - // Produces: - // - application/json - // - // Responses: - // 204: empty - // 403: forbidden - // 500: error - + // swagger:operation DELETE /orgs/{org}/public_members/{username} organization orgConcealMember + // --- + // summary: Conceal a user's membership + // produces: + // - application/json + // parameters: + // - name: org + // in: path + // description: name of the organization + // type: string + // required: true + // - name: username + // in: path + // description: username of the user + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" userToConceal := user.GetUserByParams(ctx) if ctx.Written() { return @@ -191,15 +248,27 @@ func ConcealMember(ctx *context.APIContext) { // DeleteMember remove a member from an organization func DeleteMember(ctx *context.APIContext) { - // swagger:route DELETE /orgs/{orgname}/members/{username} organization orgDeleteMember - // - // Produces: - // - application/json - // - // Responses: - // 204: empty - // 500: error - + // swagger:operation DELETE /orgs/{org}/members/{username} organization orgDeleteMember + // --- + // summary: Remove a member from an organization + // produces: + // - application/json + // parameters: + // - name: org + // in: path + // description: name of the organization + // type: string + // required: true + // - name: username + // in: path + // description: username of the user + // type: string + // required: true + // responses: + // "204": + // description: member removed + // schema: + // "$ref": "#/responses/empty" member := user.GetUserByParams(ctx) if ctx.Written() { return diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index ec55b9ebe4..c24a4aeb10 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -27,14 +27,33 @@ func listUserOrgs(ctx *context.APIContext, u *models.User, all bool) { } // ListMyOrgs list all my orgs -// see https://github.com/gogits/go-gogs-client/wiki/Organizations#list-your-organizations func ListMyOrgs(ctx *context.APIContext) { + // swagger:operation GET /user/orgs organization orgListCurrentUserOrgs + // --- + // summary: List the current user's organizations + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/OrganizationList" listUserOrgs(ctx, ctx.User, true) } // ListUserOrgs list user's orgs -// see https://github.com/gogits/go-gogs-client/wiki/Organizations#list-user-organizations func ListUserOrgs(ctx *context.APIContext) { + // swagger:operation GET /user/{username}/orgs organization orgListUserOrgs + // --- + // summary: List a user's organizations + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of user + // type: string + // responses: + // "200": + // "$ref": "#/responses/OrganizationList" u := user.GetUserByParams(ctx) if ctx.Written() { return @@ -43,14 +62,46 @@ func ListUserOrgs(ctx *context.APIContext) { } // Get get an organization -// see https://github.com/gogits/go-gogs-client/wiki/Organizations#get-an-organization func Get(ctx *context.APIContext) { + // swagger:operation GET /orgs/{org} organization orgGet + // --- + // summary: Get an organization + // produces: + // - application/json + // parameters: + // - name: org + // in: path + // description: name of the organization to get + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/Organization" ctx.JSON(200, convert.ToOrganization(ctx.Org.Organization)) } // Edit change an organization's information -// see https://github.com/gogits/go-gogs-client/wiki/Organizations#edit-an-organization func Edit(ctx *context.APIContext, form api.EditOrgOption) { + // swagger:operation PATCH /orgs/{org} organization orgEdit + // --- + // summary: Edit an organization + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: org + // in: path + // description: name of the organization to edit + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/EditOrgOption" + // responses: + // "200": + // "$ref": "#/responses/Organization" org := ctx.Org.Organization org.FullName = form.FullName org.Description = form.Description diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index dbd6ccc460..eead7dd8fd 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -15,6 +15,20 @@ import ( // ListTeams list all the teams of an organization func ListTeams(ctx *context.APIContext) { + // swagger:operation GET /orgs/{org}/teams organization orgListTeams + // --- + // summary: List an organization's teams + // produces: + // - application/json + // parameters: + // - name: org + // in: path + // description: name of the organization + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/TeamList" org := ctx.Org.Organization if err := org.GetTeams(); err != nil { ctx.Error(500, "GetTeams", err) @@ -30,11 +44,45 @@ func ListTeams(ctx *context.APIContext) { // GetTeam api for get a team func GetTeam(ctx *context.APIContext) { + // swagger:operation GET /teams/{id} organization orgGetTeam + // --- + // summary: Get a team + // produces: + // - application/json + // parameters: + // - name: id + // in: path + // description: id of the team to get + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/Team" ctx.JSON(200, convert.ToTeam(ctx.Org.Team)) } // CreateTeam api for create a team func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) { + // swagger:operation POST /orgs/{org}/teams organization orgCreateTeam + // --- + // summary: Create a team + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: org + // in: path + // description: name of the organization + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateTeamOption" + // responses: + // "201": + // "$ref": "#/responses/Team" team := &models.Team{ OrgID: ctx.Org.Organization.ID, Name: form.Name, @@ -55,6 +103,26 @@ func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) { // EditTeam api for edit a team func EditTeam(ctx *context.APIContext, form api.EditTeamOption) { + // swagger:operation PATCH /teams/{id} organization orgEditTeam + // --- + // summary: Edit a team + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: id + // in: path + // description: id of the team to edit + // type: integer + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/EditTeamOption" + // responses: + // "200": + // "$ref": "#/responses/Team" team := &models.Team{ ID: ctx.Org.Team.ID, OrgID: ctx.Org.Team.OrgID, @@ -71,6 +139,20 @@ func EditTeam(ctx *context.APIContext, form api.EditTeamOption) { // DeleteTeam api for delete a team func DeleteTeam(ctx *context.APIContext) { + // swagger:operation DELETE /teams/{id} organization orgDeleteTeam + // --- + // summary: Delete a team + // parameters: + // - name: id + // in: path + // description: id of the team to delete + // type: integer + // required: true + // responses: + // "204": + // description: team deleted + // schema: + // "$ref": "#/responses/empty" if err := models.DeleteTeam(ctx.Org.Team); err != nil { ctx.Error(500, "DeleteTeam", err) return @@ -80,6 +162,20 @@ func DeleteTeam(ctx *context.APIContext) { // GetTeamMembers api for get a team's members func GetTeamMembers(ctx *context.APIContext) { + // swagger:operation GET /teams/{id}/members organization orgListTeamMembers + // --- + // summary: List a team's members + // produces: + // - application/json + // parameters: + // - name: id + // in: path + // description: id of the team + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/UserList" if !models.IsOrganizationMember(ctx.Org.Team.OrgID, ctx.User.ID) { ctx.Status(404) return @@ -98,6 +194,25 @@ func GetTeamMembers(ctx *context.APIContext) { // AddTeamMember api for add a member to a team func AddTeamMember(ctx *context.APIContext) { + // swagger:operation PUT /teams/{id}/members/{username} organization orgAddTeamMember + // --- + // summary: Add a team member + // produces: + // - application/json + // parameters: + // - name: id + // in: path + // description: id of the team + // type: integer + // required: true + // - name: username + // in: path + // description: username of the user to add + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" u := user.GetUserByParams(ctx) if ctx.Written() { return @@ -111,6 +226,25 @@ func AddTeamMember(ctx *context.APIContext) { // RemoveTeamMember api for remove one member from a team func RemoveTeamMember(ctx *context.APIContext) { + // swagger:operation DELETE /teams/{id}/members/{username} organization orgAddTeamMember + // --- + // summary: Remove a team member + // produces: + // - application/json + // parameters: + // - name: id + // in: path + // description: id of the team + // type: integer + // required: true + // - name: username + // in: path + // description: username of the user to remove + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" u := user.GetUserByParams(ctx) if ctx.Written() { return @@ -125,6 +259,20 @@ func RemoveTeamMember(ctx *context.APIContext) { // GetTeamRepos api for get a team's repos func GetTeamRepos(ctx *context.APIContext) { + // swagger:operation GET /teams/{id}/repos organization orgListTeamRepos + // --- + // summary: List a team's repos + // produces: + // - application/json + // parameters: + // - name: id + // in: path + // description: id of the team + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/RepositoryList" team := ctx.Org.Team if err := team.GetRepositories(); err != nil { ctx.Error(500, "GetTeamRepos", err) @@ -157,6 +305,30 @@ func getRepositoryByParams(ctx *context.APIContext) *models.Repository { // AddTeamRepository api for adding a repository to a team func AddTeamRepository(ctx *context.APIContext) { + // swagger:operation PUT /teams/{id}/repos/{org}/{repo} organization orgAddTeamMember + // --- + // summary: Add a repository to a team + // produces: + // - application/json + // parameters: + // - name: id + // in: path + // description: id of the team + // type: integer + // required: true + // - name: org + // in: path + // description: organization that owns the repo to add + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo to add + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" repo := getRepositoryByParams(ctx) if ctx.Written() { return @@ -177,6 +349,32 @@ func AddTeamRepository(ctx *context.APIContext) { // RemoveTeamRepository api for removing a repository from a team func RemoveTeamRepository(ctx *context.APIContext) { + // swagger:operation DELETE /teams/{id}/repos/{org}/{repo} organization orgAddTeamMember + // --- + // summary: Remove a repository from a team + // description: This does not delete the repository, it only removes the + // repository from the team. + // produces: + // - application/json + // parameters: + // - name: id + // in: path + // description: id of the team + // type: integer + // required: true + // - name: org + // in: path + // description: organization that owns the repo to remove + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo to remove + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" repo := getRepositoryByParams(ctx) if ctx.Written() { return diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go index aed630f558..a82527e6a7 100644 --- a/routers/api/v1/repo/branch.go +++ b/routers/api/v1/repo/branch.go @@ -13,8 +13,31 @@ import ( ) // GetBranch get a branch of a repository -// see https://github.com/gogits/go-gogs-client/wiki/Repositories#get-branch func GetBranch(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/branches/{branch} repository repoGetBranch + // --- + // summary: List a repository's branches + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: branch + // in: path + // description: branch to get + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/Branch" if ctx.Repo.TreePath != "" { // if TreePath != "", then URL contained extra slashes // (i.e. "master/subbranch" instead of "master"), so branch does @@ -42,8 +65,26 @@ func GetBranch(ctx *context.APIContext) { } // ListBranches list all the branches of a repository -// see https://github.com/gogits/go-gogs-client/wiki/Repositories#list-branches func ListBranches(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/branches repository repoListBranches + // --- + // summary: List a repository's branches + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/BranchList" branches, err := ctx.Repo.Repository.GetBranches() if err != nil { ctx.Error(500, "GetBranches", err) diff --git a/routers/api/v1/repo/collaborators.go b/routers/api/v1/repo/collaborators.go index 31cb9c6b21..f35de08e50 100644 --- a/routers/api/v1/repo/collaborators.go +++ b/routers/api/v1/repo/collaborators.go @@ -13,6 +13,25 @@ import ( // ListCollaborators list a repository's collaborators func ListCollaborators(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/collaborators repository repoListCollaborators + // --- + // summary: List a repository's collaborators + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/UserList" if !ctx.Repo.IsWriter() { ctx.Error(403, "", "User does not have push access") return @@ -31,6 +50,32 @@ func ListCollaborators(ctx *context.APIContext) { // IsCollaborator check if a user is a collaborator of a repository func IsCollaborator(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/collaborators/{collaborator} repository repoCheckCollaborator + // --- + // summary: Check if a user is a collaborator of a repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: collaborator + // in: path + // description: username of the collaborator + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" + // "404": + // "$ref": "#/responses/empty" if !ctx.Repo.IsWriter() { ctx.Error(403, "", "User does not have push access") return @@ -56,8 +101,36 @@ func IsCollaborator(ctx *context.APIContext) { } } -// AddCollaborator add a collaborator of a repository +// AddCollaborator add a collaborator to a repository func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) { + // swagger:operation PUT /repos/{owner}/{repo}/collaborators/{collaborator} repository repoAddCollaborator + // --- + // summary: Add a collaborator to a repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: collaborator + // in: path + // description: username of the collaborator to add + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/AddCollaboratorOption" + // responses: + // "204": + // "$ref": "#/responses/empty" if !ctx.Repo.IsWriter() { ctx.Error(403, "", "User does not have push access") return @@ -89,6 +162,30 @@ func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) { // DeleteCollaborator delete a collaborator from a repository func DeleteCollaborator(ctx *context.APIContext) { + // swagger:operation DELETE /repos/{owner}/{repo}/collaborators/{collaborator} repository repoDeleteCollaborator + // --- + // summary: Delete a collaborator from a repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: collaborator + // in: path + // description: username of the collaborator to delete + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" if !ctx.Repo.IsWriter() { ctx.Error(403, "", "User does not have push access") return diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index 9d12a6e136..4ea81255af 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -13,8 +13,30 @@ import ( ) // GetRawFile get a file by path on a repository -// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-raw-content func GetRawFile(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/raw/{filepath} repository repoGetRawFile + // --- + // summary: Get a file from a repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: filepath + // in: path + // description: filepath of the file to get + // type: string + // required: true + // responses: + // 200: if !ctx.Repo.HasAccess() { ctx.Status(404) return @@ -40,8 +62,30 @@ func GetRawFile(ctx *context.APIContext) { } // GetArchive get archive of a repository -// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-archive func GetArchive(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/archive/{filepath} repository repoGetArchive + // --- + // summary: Get an archive of a repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: archive + // in: path + // description: archive to download, consisting of a git reference and archive + // type: string + // required: true + // responses: + // 200: repoPath := models.RepoPath(ctx.Params(":username"), ctx.Params(":reponame")) gitRepo, err := git.OpenRepository(repoPath) if err != nil { @@ -55,6 +99,29 @@ func GetArchive(ctx *context.APIContext) { // GetEditorconfig get editor config of a repository func GetEditorconfig(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/editorconfig/{filepath} repository repoGetEditorConfig + // --- + // summary: Get the EditorConfig definitions of a file in a repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: filepath + // in: path + // description: filepath of file to get + // type: string + // required: true + // responses: + // 200: ec, err := ctx.Repo.GetEditorconfig() if err != nil { if git.IsErrNotExist(err) { diff --git a/routers/api/v1/repo/fork.go b/routers/api/v1/repo/fork.go index 2f3addf692..90301cc35e 100644 --- a/routers/api/v1/repo/fork.go +++ b/routers/api/v1/repo/fork.go @@ -14,15 +14,25 @@ import ( // ListForks list a repository's forks func ListForks(ctx *context.APIContext) { - // swagger:route GET /repos/{owner}/{repo}/forks repository listForks - // - // Produces: - // - application/json - // - // Responses: - // 200: RepositoryList - // 500: error - + // swagger:operation GET /repos/{owner}/{repo}/forks repository listForks + // --- + // summary: List a repository's forks + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/RepositoryList" forks, err := ctx.Repo.Repository.GetForks() if err != nil { ctx.Error(500, "GetForks", err) @@ -42,17 +52,29 @@ func ListForks(ctx *context.APIContext) { // CreateFork create a fork of a repo func CreateFork(ctx *context.APIContext, form api.CreateForkOption) { - // swagger:route POST /repos/{owner}/{repo}/forks repository createFork - // - // Produces: - // - application/json - // - // Responses: - // 202: Repository - // 403: forbidden - // 422: validationError - // 500: error - + // swagger:operation POST /repos/{owner}/{repo}/forks repository createFork + // --- + // summary: Fork a repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo to fork + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo to fork + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateForkOption" + // responses: + // "202": + // "$ref": "#/responses/Repository" repo := ctx.Repo.Repository var forker *models.User // user/org that will own the fork if form.Organization == nil { diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go index 72dfeff3d0..2464cc7bd7 100644 --- a/routers/api/v1/repo/hook.go +++ b/routers/api/v1/repo/hook.go @@ -15,15 +15,25 @@ import ( // ListHooks list all hooks of a repository func ListHooks(ctx *context.APIContext) { - // swagger:route GET /repos/{username}/{reponame}/hooks repository repoListHooks - // - // Produces: - // - application/json - // - // Responses: - // 200: HookList - // 500: error - + // swagger:operation GET /repos/{owner}/{repo}/hooks repository repoListHooks + // --- + // summary: List the hooks in a repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/HookList" hooks, err := models.GetWebhooksByRepoID(ctx.Repo.Repository.ID) if err != nil { ctx.Error(500, "GetWebhooksByRepoID", err) @@ -39,6 +49,30 @@ func ListHooks(ctx *context.APIContext) { // GetHook get a repo's hook by id func GetHook(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/hooks/{id} repository repoGetHook + // --- + // summary: Get a hook + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of the hook to get + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/Hook" repo := ctx.Repo hookID := ctx.ParamsInt64(":id") hook, err := utils.GetRepoHook(ctx, repo.Repository.ID, hookID) @@ -50,19 +84,31 @@ func GetHook(ctx *context.APIContext) { // CreateHook create a hook for a repository func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { - // swagger:route POST /repos/{username}/{reponame}/hooks repository repoCreateHook - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 200: Hook - // 422: validationError - // 500: error - + // swagger:operation POST /repos/{owner}/{repo}/hooks repository repoCreateHook + // --- + // summary: Create a hook + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateHookOption" + // responses: + // "200": + // "$ref": "#/responses/Hook" if !utils.CheckCreateHookOption(ctx, &form) { return } @@ -71,32 +117,61 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { // EditHook modify a hook of a repository func EditHook(ctx *context.APIContext, form api.EditHookOption) { - // swagger:route PATCH /repos/{username}/{reponame}/hooks/{id} repository repoEditHook - // - // Produces: - // - application/json - // - // Responses: - // 200: Hook - // 422: validationError - // 500: error - + // swagger:operation PATCH /repos/{owner}/{repo}/hooks/{id} repository repoEditHook + // --- + // summary: Edit a hook in a repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/EditHookOption" + // responses: + // "200": + // "$ref": "#/responses/Hook" hookID := ctx.ParamsInt64(":id") utils.EditRepoHook(ctx, &form, hookID) } // DeleteHook delete a hook of a repository func DeleteHook(ctx *context.APIContext) { - // swagger:route DELETE /repos/{username}/{reponame}/hooks/{id} repository repoDeleteHook - // - // Produces: - // - application/json - // - // Responses: - // 204: empty - // 404: notFound - // 500: error - + // swagger:operation DELETE /repos/{user}/{repo}/hooks/{id} repository repoDeleteHook + // --- + // summary: Delete a hook in a repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of the hook to delete + // type: integer + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" + // "404": + // "$ref": "#/responses/notFound" if err := models.DeleteWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil { if models.IsErrWebhookNotExist(err) { ctx.Status(404) diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 2debe67c3b..08815ee074 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -18,6 +18,33 @@ import ( // ListIssues list the issues of a repository func ListIssues(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/issues issue issueListIssues + // --- + // summary: List a repository's issues + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: state + // in: query + // description: whether issue is open or closed + // type: string + // - name: page + // in: query + // description: page number of requested issues + // type: integer + // responses: + // "200": + // "$ref": "#/responses/IssueList" var isClosed util.OptionalBool switch ctx.Query("state") { case "closed": @@ -50,6 +77,30 @@ func ListIssues(ctx *context.APIContext) { // GetIssue get an issue of a repository func GetIssue(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/issues/{id} issue issueGetIssue + // --- + // summary: Get an issue by id + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of the issue to get + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/Issue" issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrIssueNotExist(err) { @@ -64,6 +115,31 @@ func GetIssue(ctx *context.APIContext) { // CreateIssue create an issue of a repository func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { + // swagger:operation POST /repos/{owner}/{repo}/issues issue issueCreateIssue + // --- + // summary: Create an issue + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateIssueOption" + // responses: + // "201": + // "$ref": "#/responses/Issue" issue := &models.Issue{ RepoID: ctx.Repo.Repository.ID, Title: form.Title, @@ -114,6 +190,36 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { // EditIssue modify an issue of a repository func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { + // swagger:operation PATCH /repos/{owner}/{repo}/issues/{id} issue issueEditIssue + // --- + // summary: Edit an issue + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of the issue to edit + // type: integer + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/EditIssueOption" + // responses: + // "201": + // "$ref": "#/responses/Issue" issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrIssueNotExist(err) { diff --git a/routers/api/v1/repo/issue_comment.go b/routers/api/v1/repo/issue_comment.go index b57511a2de..f0b0353d1b 100644 --- a/routers/api/v1/repo/issue_comment.go +++ b/routers/api/v1/repo/issue_comment.go @@ -15,6 +15,34 @@ import ( // ListIssueComments list all the comments of an issue func ListIssueComments(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/issue/{index}/comments issue issueGetComments + // --- + // summary: List all comments on an issue + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: index of the issue + // type: integer + // required: true + // - name: string + // in: query + // description: if provided, only comments updated since the specified time are returned. + // type: string + // responses: + // "200": + // "$ref": "#/responses/CommentList" var since time.Time if len(ctx.Query("since")) > 0 { since, _ = time.Parse(time.RFC3339, ctx.Query("since")) @@ -44,8 +72,31 @@ func ListIssueComments(ctx *context.APIContext) { ctx.JSON(200, &apiComments) } -// ListRepoIssueComments returns all issue-comments for an issue +// ListRepoIssueComments returns all issue-comments for a repo func ListRepoIssueComments(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/issues/comments issue issueGetRepoComments + // --- + // summary: List all comments in a repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: string + // in: query + // description: if provided, only comments updated since the provided time are returned. + // type: string + // responses: + // "200": + // "$ref": "#/responses/CommentList" var since time.Time if len(ctx.Query("since")) > 0 { since, _ = time.Parse(time.RFC3339, ctx.Query("since")) @@ -70,6 +121,36 @@ func ListRepoIssueComments(ctx *context.APIContext) { // CreateIssueComment create a comment for an issue func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOption) { + // swagger:operation POST /repos/{owner}/{repo}/issues/{index}/comments issue issueCreateComment + // --- + // summary: Add a comment to an issue + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: index of the issue + // type: integer + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateIssueOption" + // responses: + // "201": + // "$ref": "#/responses/Comment" issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { ctx.Error(500, "GetIssueByIndex", err) @@ -87,6 +168,36 @@ func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOpti // EditIssueComment modify a comment of an issue func EditIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) { + // swagger:operation PATCH /repos/{owner}/{repo}/comments/{id} issue issueEditComment + // --- + // summary: Edit a comment + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of the comment to edit + // type: integer + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/EditIssueCommentOption" + // responses: + // "200": + // "$ref": "#/responses/Comment" comment, err := models.GetCommentByID(ctx.ParamsInt64(":id")) if err != nil { if models.IsErrCommentNotExist(err) { @@ -115,6 +226,28 @@ func EditIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) // DeleteIssueComment delete a comment from an issue func DeleteIssueComment(ctx *context.APIContext) { + // swagger:operation DELETE /repos/{owner}/{repo}/comments/{id} issue issueDeleteComment + // --- + // summary: Delete a comment + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of comment to delete + // type: integer + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" comment, err := models.GetCommentByID(ctx.ParamsInt64(":id")) if err != nil { if models.IsErrCommentNotExist(err) { diff --git a/routers/api/v1/repo/issue_label.go b/routers/api/v1/repo/issue_label.go index 2eec743e70..fde919e506 100644 --- a/routers/api/v1/repo/issue_label.go +++ b/routers/api/v1/repo/issue_label.go @@ -13,6 +13,32 @@ import ( // ListIssueLabels list all the labels of an issue func ListIssueLabels(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/issues/{index}/labels issue issueGetLabels + // --- + // summary: Get an issue's labels + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: index + // in: path + // description: index of the issue + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/LabelList" + // "404": + // "$ref": "#/responses/notFound" issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrIssueNotExist(err) { @@ -32,6 +58,36 @@ func ListIssueLabels(ctx *context.APIContext) { // AddIssueLabels add labels for an issue func AddIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) { + // swagger:operation POST /repos/{owner}/{repo}/issue/{index}/labels issue issueAddLabel + // --- + // summary: Add a label to an issue + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: index + // in: path + // description: index of the issue + // type: integer + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/IssueLabelsOption" + // responses: + // "200": + // "$ref": "#/responses/LabelList" if !ctx.Repo.IsWriter() { ctx.Status(403) return @@ -73,6 +129,35 @@ func AddIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) { // DeleteIssueLabel delete a label for an issue func DeleteIssueLabel(ctx *context.APIContext) { + // swagger:operation DELETE /repos/{owner}/{repo}/issue/{index}/labels/{id} issue issueRemoveLabel + // --- + // summary: Remove a label from an issue + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: index + // in: path + // description: index of the issue + // type: integer + // required: true + // - name: id + // in: path + // description: id of the label to remove + // type: integer + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" if !ctx.Repo.IsWriter() { ctx.Status(403) return @@ -108,6 +193,36 @@ func DeleteIssueLabel(ctx *context.APIContext) { // ReplaceIssueLabels replace labels for an issue func ReplaceIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) { + // swagger:operation PUT /repos/{owner}/{repo}/issue/{index}/labels issue issueReplaceLabels + // --- + // summary: Replace an issue's labels + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: index + // in: path + // description: index of the issue + // type: integer + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/IssueLabelsOption" + // responses: + // "200": + // "$ref": "#/responses/LabelList" if !ctx.Repo.IsWriter() { ctx.Status(403) return @@ -149,6 +264,30 @@ func ReplaceIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) { // ClearIssueLabels delete all the labels for an issue func ClearIssueLabels(ctx *context.APIContext) { + // swagger:operation DELETE /repos/{owner}/{repo}/issue/{index}/labels issue issueClearLabels + // --- + // summary: Remove all labels from an issue + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: index + // in: path + // description: index of the issue + // type: integer + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" if !ctx.Repo.IsWriter() { ctx.Status(403) return diff --git a/routers/api/v1/repo/issue_tracked_time.go b/routers/api/v1/repo/issue_tracked_time.go index 3962a7b0e2..15d898d5d5 100644 --- a/routers/api/v1/repo/issue_tracked_time.go +++ b/routers/api/v1/repo/issue_tracked_time.go @@ -20,15 +20,30 @@ func trackedTimesToAPIFormat(trackedTimes []*models.TrackedTime) []*api.TrackedT // ListTrackedTimes list all the tracked times of an issue func ListTrackedTimes(ctx *context.APIContext) { - // swagger:route GET /repos/{username}/{reponame}/issues/{issue}/times repository issueTrackedTimes - // - // Produces: - // - application/json - // - // Responses: - // 200: TrackedTimes - // 404: error - // 500: error + // swagger:operation GET /repos/{owner}/{repo}/issues/{index}/times issue issueTrackedTimes + // --- + // summary: List an issue's tracked times + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: index of the issue + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/TrackedTimeList" if !ctx.Repo.Repository.IsTimetrackerEnabled() { ctx.Error(404, "IsTimetrackerEnabled", "Timetracker is diabled") return @@ -54,17 +69,40 @@ func ListTrackedTimes(ctx *context.APIContext) { // AddTime adds time manual to the given issue func AddTime(ctx *context.APIContext, form api.AddTimeOption) { - // swagger:route Post /repos/{username}/{reponame}/issues/{issue}/times repository addTime - // - // Produces: - // - application/json - // - // Responses: - // 200: TrackedTime - // 400: error - // 403: error - // 404: error - // 500: error + // swagger:operation Post /repos/{owner}/{repo}/issues/{index}/times issue issueAddTime + // --- + // summary: Add a tracked time to a issue + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: index of the issue to add tracked time to + // type: integer + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/AddTimeOption" + // responses: + // "200": + // "$ref": "#/responses/TrackedTime" + // "400": + // "$ref": "#/responses/error" + // "403": + // "$ref": "#/responses/error" issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrIssueNotExist(err) { @@ -93,16 +131,30 @@ func AddTime(ctx *context.APIContext, form api.AddTimeOption) { // ListTrackedTimesByUser lists all tracked times of the user func ListTrackedTimesByUser(ctx *context.APIContext) { - // swagger:route GET /repos/{username}/{reponame}/times/{timetrackingusername} user userTrackedTimes - // - // Produces: - // - application/json - // - // Responses: - // 200: TrackedTimes - // 400: error - // 404: error - // 500: error + // swagger:operation GET /repos/{owner}/{repo}/times/{tracker} user userTrackedTimes + // --- + // summary: List a user's tracked times in a repo + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: user + // in: path + // description: username of user + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/TrackedTimeList" if !ctx.Repo.Repository.IsTimetrackerEnabled() { ctx.JSON(400, struct{ Message string }{Message: "time tracking disabled"}) return @@ -131,17 +183,27 @@ func ListTrackedTimesByUser(ctx *context.APIContext) { ctx.JSON(200, &apiTrackedTimes) } -// ListTrackedTimesByRepository lists all tracked times of the user +// ListTrackedTimesByRepository lists all tracked times of the repository func ListTrackedTimesByRepository(ctx *context.APIContext) { - // swagger:route GET /repos/{username}/{reponame}/times repository repoTrackedTimes - // - // Produces: - // - application/json - // - // Responses: - // 200: TrackedTimes - // 400: error - // 500: error + // swagger:operation GET /repos/{owner}/{repo}/times repository repoTrackedTimes + // --- + // summary: List a repo's tracked times + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/TrackedTimeList" if !ctx.Repo.Repository.IsTimetrackerEnabled() { ctx.JSON(400, struct{ Message string }{Message: "time tracking disabled"}) return @@ -158,14 +220,14 @@ func ListTrackedTimesByRepository(ctx *context.APIContext) { // ListMyTrackedTimes lists all tracked times of the current user func ListMyTrackedTimes(ctx *context.APIContext) { - // swagger:route GET /user/times user userTrackedTimes - // - // Produces: - // - application/json - // - // Responses: - // 200: TrackedTimes - // 500: error + // swagger:operation GET /user/times user userCurrentTrackedTimes + // --- + // summary: List the current user's tracked times + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/TrackedTimeList" trackedTimes, err := models.GetTrackedTimes(models.FindTrackedTimesOptions{UserID: ctx.User.ID}) if err != nil { ctx.Error(500, "GetTrackedTimesByUser", err) diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go index 546cc40e61..a20f4c829e 100644 --- a/routers/api/v1/repo/key.go +++ b/routers/api/v1/repo/key.go @@ -20,8 +20,26 @@ func composeDeployKeysAPILink(repoPath string) string { } // ListDeployKeys list all the deploy keys of a repository -// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#list-deploy-keys func ListDeployKeys(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/keys repository repoListKeys + // --- + // summary: List a repository's keys + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/DeployKeyList" keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID) if err != nil { ctx.Error(500, "ListDeployKeys", err) @@ -42,8 +60,31 @@ func ListDeployKeys(ctx *context.APIContext) { } // GetDeployKey get a deploy key by id -// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#get-a-deploy-key func GetDeployKey(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/keys/{id} repository repoGetKey + // --- + // summary: Get a repository's key by id + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of the key to get + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/DeployKey" key, err := models.GetDeployKeyByID(ctx.ParamsInt64(":id")) if err != nil { if models.IsErrDeployKeyNotExist(err) { @@ -85,8 +126,32 @@ func HandleAddKeyError(ctx *context.APIContext, err error) { } // CreateDeployKey create deploy key for a repository -// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#add-a-new-deploy-key func CreateDeployKey(ctx *context.APIContext, form api.CreateKeyOption) { + // swagger:operation POST /repos/{owner}/{repo}/keys repository repoCreateKey + // --- + // summary: Add a key to a repository + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateKeyOption" + // responses: + // "201": + // "$ref": "#/responses/DeployKey" content, err := models.CheckPublicKeyString(form.Key) if err != nil { HandleCheckKeyStringError(ctx, err) @@ -105,8 +170,29 @@ func CreateDeployKey(ctx *context.APIContext, form api.CreateKeyOption) { } // DeleteDeploykey delete deploy key for a repository -// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#remove-a-deploy-key func DeleteDeploykey(ctx *context.APIContext) { + // swagger:operation DELETE /repos/{owner}/{repo}/keys/{id} repository repoDeleteKey + // --- + // summary: Delete a key from a repository + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of the key to delete + // type: integer + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" if err := models.DeleteDeployKey(ctx.User, ctx.ParamsInt64(":id")); err != nil { if models.IsErrKeyAccessDenied(err) { ctx.Error(403, "", "You do not have access to this key") diff --git a/routers/api/v1/repo/label.go b/routers/api/v1/repo/label.go index c932fb1585..cb724c7182 100644 --- a/routers/api/v1/repo/label.go +++ b/routers/api/v1/repo/label.go @@ -15,6 +15,25 @@ import ( // ListLabels list all the labels of a repository func ListLabels(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/labels issue issueListLabels + // --- + // summary: Get all of a repository's labels + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/LabelList" labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Query("sort")) if err != nil { ctx.Error(500, "GetLabelsByRepoID", err) @@ -30,6 +49,30 @@ func ListLabels(ctx *context.APIContext) { // GetLabel get label by repository and label id func GetLabel(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/labels/{id} issue issueGetLabel + // --- + // summary: Get a single label + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of the label to get + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/Label" var ( label *models.Label err error @@ -54,6 +97,31 @@ func GetLabel(ctx *context.APIContext) { // CreateLabel create a label for a repository func CreateLabel(ctx *context.APIContext, form api.CreateLabelOption) { + // swagger:operation POST /repos/{owner}/{repo}/labels issue issueCreateLabel + // --- + // summary: Create a label + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateLabelOption" + // responses: + // "201": + // "$ref": "#/responses/Label" if !ctx.Repo.IsWriter() { ctx.Status(403) return @@ -73,6 +141,36 @@ func CreateLabel(ctx *context.APIContext, form api.CreateLabelOption) { // EditLabel modify a label for a repository func EditLabel(ctx *context.APIContext, form api.EditLabelOption) { + // swagger:operation PATCH /repos/{owner}/{repo}/labels/{id} issue issueEditLabel + // --- + // summary: Update a label + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of the label to edit + // type: integer + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/EditLabelOption" + // responses: + // "200": + // "$ref": "#/responses/Label" if !ctx.Repo.IsWriter() { ctx.Status(403) return @@ -103,6 +201,28 @@ func EditLabel(ctx *context.APIContext, form api.EditLabelOption) { // DeleteLabel delete a label for a repository func DeleteLabel(ctx *context.APIContext) { + // swagger:operation DELETE /repos/{owner}/{repo}/labels/{id} issue issueDeleteLabel + // --- + // summary: Delete a label + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of the label to delete + // type: integer + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" if !ctx.Repo.IsWriter() { ctx.Status(403) return diff --git a/routers/api/v1/repo/milestone.go b/routers/api/v1/repo/milestone.go index ef32ed8989..0e597a9db0 100644 --- a/routers/api/v1/repo/milestone.go +++ b/routers/api/v1/repo/milestone.go @@ -15,6 +15,14 @@ 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) @@ -30,6 +38,41 @@ func ListMilestones(ctx *context.APIContext) { // GetMilestone get a milestone for a repository func GetMilestone(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/milestones issue issueGetMilestones + // --- + // summary: Get all of a repository's milestones + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of the milestone to get + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/MilestoneList" milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) if err != nil { if models.IsErrMilestoneNotExist(err) { @@ -44,6 +87,31 @@ func GetMilestone(ctx *context.APIContext) { // CreateMilestone create a milestone for a repository func CreateMilestone(ctx *context.APIContext, form api.CreateMilestoneOption) { + // swagger:operation POST /repos/{owner}/{repo}/milestones issue issueCreateMilestone + // --- + // summary: Create a milestone + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateMilestoneOption" + // responses: + // "201": + // "$ref": "#/responses/Milestone" if form.Deadline == nil { defaultDeadline, _ := time.ParseInLocation("2006-01-02", "9999-12-31", time.Local) form.Deadline = &defaultDeadline @@ -65,6 +133,31 @@ func CreateMilestone(ctx *context.APIContext, form api.CreateMilestoneOption) { // EditMilestone modify a milestone for a repository func EditMilestone(ctx *context.APIContext, form api.EditMilestoneOption) { + // swagger:operation PATCH /repos/{owner}/{repo}/milestones/{id} issue issueEditMilestone + // --- + // summary: Update a milestone + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/EditMilestoneOption" + // responses: + // "200": + // "$ref": "#/responses/Milestone" milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) if err != nil { if models.IsErrMilestoneNotExist(err) { @@ -94,6 +187,28 @@ func EditMilestone(ctx *context.APIContext, form api.EditMilestoneOption) { // DeleteMilestone delete a milestone for a repository func DeleteMilestone(ctx *context.APIContext) { + // swagger:operation DELETE /repos/{owner}/{repo}/milestones/{id} issue issueDeleteMilestone + // --- + // summary: Delete a milestone + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: body + // in: path + // description: id of the milestone to delete + // type: integer + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" if err := models.DeleteMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil { ctx.Error(500, "DeleteMilestoneByRepoID", err) return diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index d1b73c6cf7..50b864e323 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -18,6 +18,25 @@ import ( // ListPullRequests returns a list of all PRs func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions) { + // swagger:operation GET /repos/{owner}/{repo}/pulls repository repoListPullRequests + // --- + // summary: List a repo's pull requests + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/PullRequestList" prs, maxResults, err := models.PullRequests(ctx.Repo.Repository.ID, &models.PullRequestsOptions{ Page: ctx.QueryInt("page"), State: ctx.QueryTrim("state"), @@ -58,6 +77,30 @@ func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions) // GetPullRequest returns a single PR based on index func GetPullRequest(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/pulls/{index} repository repoGetPullRequest + // --- + // summary: Get a pull request + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: index + // in: path + // description: index of the pull request to get + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/PullRequest" pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrPullRequestNotExist(err) { @@ -81,6 +124,31 @@ func GetPullRequest(ctx *context.APIContext) { // CreatePullRequest does what it says func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption) { + // swagger:operation POST /repos/{owner}/{repo}/pulls repository repoCreatePullRequest + // --- + // summary: Create a pull request + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreatePullRequestOption" + // responses: + // "201": + // "$ref": "#/responses/PullRequest" var ( repo = ctx.Repo.Repository labelIDs []int64 @@ -204,6 +272,36 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption // EditPullRequest does what it says func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) { + // swagger:operation PATCH /repos/{owner}/{repo}/pulls/{index} repository repoEditPullRequest + // --- + // summary: Update a pull request + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: index + // in: path + // description: index of the pull request to edit + // type: integer + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/EditPullRequestOption" + // responses: + // "201": + // "$ref": "#/responses/PullRequest" pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrPullRequestNotExist(err) { @@ -283,13 +381,42 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) { return } + // TODO this should be 200, not 201 ctx.JSON(201, pr.APIFormat()) } // IsPullRequestMerged checks if a PR exists given an index -// - Returns 204 if it exists -// Otherwise 404 func IsPullRequestMerged(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/pulls/{index}/merge repository repoPullRequestIsMerged + // --- + // summary: Check if a pull request has been merged + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: index + // in: path + // description: index of the pull request + // type: integer + // required: true + // 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) { @@ -308,6 +435,32 @@ func IsPullRequestMerged(ctx *context.APIContext) { // MergePullRequest merges a PR given an index func MergePullRequest(ctx *context.APIContext) { + // swagger:operation POST /repos/{owner}/{repo}/pulls/{index}/merge repository repoMergePullRequest + // --- + // summary: Merge a pull request + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: index + // in: path + // description: index of the pull request to merge + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/empty" + // "405": + // "$ref": "#/responses/empty" pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrPullRequestNotExist(err) { diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go index 78289a6a2a..17cddc5652 100644 --- a/routers/api/v1/repo/release.go +++ b/routers/api/v1/repo/release.go @@ -13,6 +13,30 @@ import ( // GetRelease get a single release of a repository func GetRelease(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/releases repository repoGetRelease + // --- + // summary: Get a release + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: id of the release to get + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/Release" id := ctx.ParamsInt64(":id") release, err := models.GetReleaseByID(id) if err != nil { @@ -32,6 +56,25 @@ func GetRelease(ctx *context.APIContext) { // ListReleases list a repository's releases func ListReleases(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/releases repository repoListReleases + // --- + // summary: List a repo's releases + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/ReleaseList" releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, models.FindReleasesOptions{ IncludeDrafts: ctx.Repo.AccessMode >= models.AccessModeWrite, IncludeTags: false, @@ -53,6 +96,31 @@ func ListReleases(ctx *context.APIContext) { // CreateRelease create a release func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) { + // swagger:operation GET /repos/{owner}/{repo}/releases repository repoCreateRelease + // --- + // summary: Create a release + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateReleaseOption" + // responses: + // "201": + // "$ref": "#/responses/Release" if ctx.Repo.AccessMode < models.AccessModeWrite { ctx.Status(403) return @@ -110,6 +178,36 @@ func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) { // EditRelease edit a release func EditRelease(ctx *context.APIContext, form api.EditReleaseOption) { + // swagger:operation PATCH /repos/{owner}/{repo}/releases/{id} repository repoEditRelease + // --- + // summary: Update a release + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of the release to edit + // type: integer + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/EditReleaseOption" + // responses: + // "200": + // "$ref": "#/responses/Release" if ctx.Repo.AccessMode < models.AccessModeWrite { ctx.Status(403) return @@ -163,6 +261,28 @@ func EditRelease(ctx *context.APIContext, form api.EditReleaseOption) { // DeleteRelease delete a release from a repository func DeleteRelease(ctx *context.APIContext) { + // swagger:operation DELETE /repos/{owner}/{repo}/releases/{id} repository repoDeleteRelease + // --- + // summary: Delete a release + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: id + // in: path + // description: id of the release to delete + // type: integer + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" if ctx.Repo.AccessMode < models.AccessModeWrite { ctx.Status(403) return diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 34f4c5fa16..36e644373c 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -20,45 +20,40 @@ import ( "code.gitea.io/gitea/routers/api/v1/convert" ) -// SearchRepoOption options when searching repositories -// swagger:parameters repoSearch -type SearchRepoOption struct { // TODO: Move SearchRepoOption to Gitea SDK - // Keyword to search - // - // in: query - Keyword string `json:"q"` - // Repository owner to search - // - // in: query - OwnerID int64 `json:"uid"` - // Limit of result - // - // maximum: setting.ExplorePagingNum - // in: query - PageSize int `json:"limit"` - // Type of repository to search, related to owner - // - // in: query - SearchMode string `json:"mode"` - // Search only owners repositories - // Has effect only if owner is provided and mode is not "collaborative" - // - // in: query - OwnerExclusive bool `json:"exclusive"` -} - // Search repositories via options func Search(ctx *context.APIContext) { - // swagger:route GET /repos/search repository repoSearch - // - // Produces: - // - application/json - // - // Responses: - // 200: SearchResults - // 422: validationError - // 500: SearchError - + // swagger:operation GET /repos/search repository repoSearch + // --- + // summary: Search for repositories + // produces: + // - application/json + // parameters: + // - name: q + // in: query + // description: keyword + // type: string + // - name: uid + // in: query + // description: if provided, will return only repos owned by the user with the given id + // type: integer + // - name: limit + // in: query + // description: maximum number of repos to return + // type: integer + // - name: mode + // in: query + // description: type of repository to search for. Supported values are + // "fork", "source", "mirror" and "collaborative" + // type: string + // - name: exclusive + // in: query + // description: only search for repositories owned by the authenticated user + // type: boolean + // responses: + // "200": + // "$ref": "#/responses/SearchResults" + // "422": + // "$ref": "#/responses/validationError" opts := &models.SearchRepoOptions{ Keyword: strings.Trim(ctx.Query("q"), " "), OwnerID: ctx.QueryInt64("uid"), @@ -187,22 +182,23 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR // Create one repository of mine func Create(ctx *context.APIContext, opt api.CreateRepoOption) { - // swagger:route POST /user/repos repository user createCurrentUserRepo - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 201: Repository - // 403: forbidden - // 422: validationError - // 500: error - - // Shouldn't reach this condition, but just in case. + // swagger:operation POST /user/repos repository user createCurrentUserRepo + // --- + // summary: Create a repository + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateRepoOption" + // responses: + // "201": + // "$ref": "#/responses/Repository" if ctx.User.IsOrganization() { + // Shouldn't reach this condition, but just in case. ctx.Error(422, "", "not allowed creating repository for organization") return } @@ -211,20 +207,30 @@ func Create(ctx *context.APIContext, opt api.CreateRepoOption) { // CreateOrgRepo create one repository of the organization func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) { - // swagger:route POST /org/{org}/repos organization createOrgRepo - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 201: Repository - // 422: validationError - // 403: forbidden - // 500: error - + // swagger:operation POST /org/{org}/repos organization createOrgRepo + // --- + // summary: Create a repository in an organization + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: org + // in: path + // description: name of organization + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateRepoOption" + // responses: + // "201": + // "$ref": "#/responses/Repository" + // "422": + // "$ref": "#/responses/validationError" + // "403": + // "$ref": "#/responses/forbidden" org, err := models.GetOrgByName(ctx.Params(":org")) if err != nil { if models.IsErrOrgNotExist(err) { @@ -244,19 +250,21 @@ func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) { // Migrate migrate remote git repository to gitea func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { - // swagger:route POST /repos/migrate repository repoMigrate - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 201: Repository - // 422: validationError - // 500: error - + // swagger:operation POST /repos/migrate repository repoMigrate + // --- + // summary: Migrate a remote git repository + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/MigrateRepoForm" + // responses: + // "201": + // "$ref": "#/responses/Repository" ctxUser := ctx.User // Not equal means context user is an organization, // or is another user/organization if current user is admin. @@ -329,29 +337,44 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { // Get one repository func Get(ctx *context.APIContext) { - // swagger:route GET /repos/{username}/{reponame} repository repoGet - // - // Produces: - // - application/json - // - // Responses: - // 200: Repository - // 500: error - + // swagger:operation GET /repos/{owner}/{repo} repository repoGet + // --- + // summary: Get a repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/Repository" ctx.JSON(200, ctx.Repo.Repository.APIFormat(ctx.Repo.AccessMode)) } // GetByID returns a single Repository func GetByID(ctx *context.APIContext) { - // swagger:route GET /repositories/{id} repository repoGetByID - // - // Produces: - // - application/json - // - // Responses: - // 200: Repository - // 500: error - + // swagger:operation GET /repositories/{id} repository repoGetByID + // --- + // summary: Get a repository by id + // produces: + // - application/json + // parameters: + // - name: id + // in: path + // description: id of the repo to get + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/Repository" repo, err := models.GetRepositoryByID(ctx.ParamsInt64(":id")) if err != nil { if models.IsErrRepoNotExist(err) { @@ -375,16 +398,27 @@ func GetByID(ctx *context.APIContext) { // Delete one repository func Delete(ctx *context.APIContext) { - // swagger:route DELETE /repos/{username}/{reponame} repository repoDelete - // - // Produces: - // - application/json - // - // Responses: - // 204: empty - // 403: forbidden - // 500: error - + // swagger:operation DELETE /repos/{owner}/{repo} repository repoDelete + // --- + // summary: Delete a repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo to delete + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo to delete + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" + // "403": + // "$ref": "#/responses/forbidden" if !ctx.Repo.IsAdmin() { ctx.Error(403, "", "Must have admin rights") return @@ -408,15 +442,25 @@ func Delete(ctx *context.APIContext) { // MirrorSync adds a mirrored repository to the sync queue func MirrorSync(ctx *context.APIContext) { - // swagger:route POST /repos/{username}/{reponame}/mirror-sync repository repoMirrorSync - // - // Produces: - // - application/json - // - // Responses: - // 200: empty - // 403: forbidden - + // swagger:operation POST /repos/{owner}/{repo}/mirror-sync repository repoMirrorSync + // --- + // summary: Sync a mirrored repository + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo to sync + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo to sync + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/empty" repo := ctx.Repo.Repository if !ctx.Repo.IsWriter() { diff --git a/routers/api/v1/repo/star.go b/routers/api/v1/repo/star.go index 20e7e4e508..3500eaf421 100644 --- a/routers/api/v1/repo/star.go +++ b/routers/api/v1/repo/star.go @@ -12,6 +12,25 @@ import ( // ListStargazers list a repository's stargazers func ListStargazers(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/stargazers repository repoListStargazers + // --- + // summary: List a repo's stargazers + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/UserList" stargazers, err := ctx.Repo.Repository.GetStargazers(-1) if err != nil { ctx.Error(500, "GetStargazers", err) diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go index e4cc20a50b..7f7ef1ae32 100644 --- a/routers/api/v1/repo/status.go +++ b/routers/api/v1/repo/status.go @@ -14,6 +14,34 @@ import ( // NewCommitStatus creates a new CommitStatus func NewCommitStatus(ctx *context.APIContext, form api.CreateStatusOption) { + // swagger:operation POST /repos/{owner}/{repo}/statuses/{sha} repository repoCreateStatus + // --- + // summary: Create a commit status + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: sha + // in: path + // description: sha of the commit + // type: string + // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateStatusOption" + // responses: + // "200": + // "$ref": "#/responses/StatusList" sha := ctx.Params("sha") if len(sha) == 0 { sha = ctx.Params("ref") @@ -43,10 +71,63 @@ func NewCommitStatus(ctx *context.APIContext, form api.CreateStatusOption) { // GetCommitStatuses returns all statuses for any given commit hash func GetCommitStatuses(ctx *context.APIContext) { - sha := ctx.Params("sha") - if len(sha) == 0 { - sha = ctx.Params("ref") - } + // swagger:operation GET /repos/{owner}/{repo}/statuses/{sha} repository repoListStatuses + // --- + // summary: Get a commit's statuses + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: sha + // in: path + // description: sha of the commit + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/StatusList" + getCommitStatuses(ctx, ctx.Params("sha")) +} + +// GetCommitStatusesByRef returns all statuses for any given commit ref +func GetCommitStatusesByRef(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/commits/{ref}/statuses repository repoListStatusesByRef + // --- + // summary: Get a commit's statuses, by branch/tag/commit reference + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: ref + // in: path + // description: name of branch/tag/commit + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/StatusList" + getCommitStatuses(ctx, ctx.Params("ref")) +} + +func getCommitStatuses(ctx *context.APIContext, sha string) { if len(sha) == 0 { ctx.Error(400, "ref/sha not given", nil) return @@ -78,12 +159,33 @@ type combinedCommitStatus struct { URL string `json:"url"` } -// GetCombinedCommitStatus returns the combined status for any given commit hash -func GetCombinedCommitStatus(ctx *context.APIContext) { - sha := ctx.Params("sha") - if len(sha) == 0 { - sha = ctx.Params("ref") - } +// GetCombinedCommitStatusByRef returns the combined status for any given commit hash +func GetCombinedCommitStatusByRef(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/commits/{ref}/statuses repository repoGetCombinedStatusByRef + // --- + // summary: Get a commit's combined status, by branch/tag/commit reference + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: ref + // in: path + // description: name of branch/tag/commit + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/Status" + sha := ctx.Params("ref") if len(sha) == 0 { ctx.Error(400, "ref/sha not given", nil) return diff --git a/routers/api/v1/repo/subscriber.go b/routers/api/v1/repo/subscriber.go index d9d9a6c96d..737ae89f01 100644 --- a/routers/api/v1/repo/subscriber.go +++ b/routers/api/v1/repo/subscriber.go @@ -12,6 +12,25 @@ import ( // ListSubscribers list a repo's subscribers (i.e. watchers) func ListSubscribers(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/subscribers repository repoListSubscribers + // --- + // summary: List a repo's watchers + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/UserList" subscribers, err := ctx.Repo.Repository.GetWatchers(0) if err != nil { ctx.Error(500, "GetWatchers", err) diff --git a/routers/api/v1/swagger/issue.go b/routers/api/v1/swagger/issue.go new file mode 100644 index 0000000000..1ebb17b249 --- /dev/null +++ b/routers/api/v1/swagger/issue.go @@ -0,0 +1,69 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package swagger + +import ( + api "code.gitea.io/sdk/gitea" +) + +// swagger:response Issue +type swaggerResponseIssue struct { + // in:body + Body api.Issue `json:"body"` +} + +// swagger:response IssueList +type swaggerResponseIssueList struct { + // in:body + Body []api.Issue `json:"body"` +} + +// swagger:response Comment +type swaggerResponseComment struct { + // in:body + Body api.Comment `json:"body"` +} + +// swagger:response CommentList +type swaggerResponseCommentList struct { + // in:body + Body []api.Comment `json:"body"` +} + +// swagger:response Label +type swaggerResponseLabel struct { + // in:body + Body api.Label `json:"body"` +} + +// swagger:response LabelList +type swaggerResponseLabelList struct { + // in:body + Body []api.Label `json:"body"` +} + +// swagger:response Milestone +type swaggerResponseMilestone struct { + // in:body + Body api.Milestone `json:"body"` +} + +// swagger:response MilestoneList +type swaggerResponseMilestoneList struct { + // in:body + Body []api.Milestone `json:"body"` +} + +// swagger:response TrackedTime +type swaggerResponseTrackedTime struct { + // in:body + Body api.TrackedTime `json:"body"` +} + +// swagger:response TrackedTimeList +type swaggerResponseTrackedTimeList struct { + // in:body + Body []api.TrackedTime `json:"body"` +} diff --git a/routers/api/v1/swagger/key.go b/routers/api/v1/swagger/key.go new file mode 100644 index 0000000000..344d54c878 --- /dev/null +++ b/routers/api/v1/swagger/key.go @@ -0,0 +1,45 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package swagger + +import ( + api "code.gitea.io/sdk/gitea" +) + +// swagger:response PublicKey +type swaggerResponsePublicKey struct { + // in:body + Body api.PublicKey `json:"body"` +} + +// swagger:response PublicKeyList +type swaggerResponsePublicKeyList struct { + // in:body + Body []api.PublicKey `json:"body"` +} + +// swagger:response GPGKey +type swaggerResponseGPGKey struct { + // in:body + Body api.GPGKey `json:"body"` +} + +// swagger:response GPGKeyList +type swaggerResponseGPGKeyList struct { + // in:body + Body []api.GPGKey `json:"body"` +} + +// swagger:response DeployKey +type swaggerResponseDeployKey struct { + // in:body + Body api.DeployKey `json:"body"` +} + +// swagger:response DeployKeyList +type swaggerResponseDeployKeyList struct { + // in:body + Body []api.DeployKey `json:"body"` +} diff --git a/routers/api/v1/swagger/misc.go b/routers/api/v1/swagger/misc.go new file mode 100644 index 0000000000..8ec0d53a79 --- /dev/null +++ b/routers/api/v1/swagger/misc.go @@ -0,0 +1,15 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package swagger + +import ( + api "code.gitea.io/sdk/gitea" +) + +// swagger:response ServerVersion +type swaggerResponseServerVersion struct { + // in:body + Body api.ServerVersion `json:"body"` +} diff --git a/routers/api/v1/swagger/options.go b/routers/api/v1/swagger/options.go new file mode 100644 index 0000000000..31251eb3e2 --- /dev/null +++ b/routers/api/v1/swagger/options.go @@ -0,0 +1,66 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package swagger + +import ( + "code.gitea.io/gitea/modules/auth" + api "code.gitea.io/sdk/gitea" +) + +// not actually a response, just a hack to get go-swagger to include definitions +// of the various XYZOption structs + +// swagger:response parameterBodies +type swaggerParameterBodies struct { + AddCollaboratorOption api.AddCollaboratorOption + + CreateEmailOption api.CreateEmailOption + DeleteEmailOption api.DeleteEmailOption + + CreateHookOption api.CreateHookOption + EditHookOption api.EditHookOption + + CreateIssueOption api.CreateIssueOption + EditIssueOption api.EditIssueOption + + CreateIssueCommentOption api.CreateIssueCommentOption + EditIssueCommentOption api.EditIssueCommentOption + + IssueLabelsOption api.IssueLabelsOption + + CreateKeyOption api.CreateKeyOption + + CreateLabelOption api.CreateLabelOption + EditLabelOption api.EditLabelOption + + MarkdownOption api.MarkdownOption + + CreateMilestoneOption api.CreateMilestoneOption + EditMilestoneOption api.EditMilestoneOption + + CreateOrgOption api.CreateOrgOption + EditOrgOption api.EditOrgOption + + CreatePullRequestOption api.CreatePullRequestOption + EditPullRequestOption api.EditPullRequestOption + + CreateReleaseOption api.CreateReleaseOption + EditReleaseOption api.EditReleaseOption + + CreateRepoOption api.CreateRepoOption + CreateForkOption api.CreateForkOption + + CreateStatusOption api.CreateStatusOption + + CreateTeamOption api.CreateTeamOption + EditTeamOption api.EditTeamOption + + AddTimeOption api.AddTimeOption + + CreateUserOption api.CreateUserOption + EditUserOption api.EditUserOption + + MigrateRepoForm auth.MigrateRepoForm +} diff --git a/routers/api/v1/swagger/org.go b/routers/api/v1/swagger/org.go new file mode 100644 index 0000000000..46bd56646b --- /dev/null +++ b/routers/api/v1/swagger/org.go @@ -0,0 +1,33 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package swagger + +import ( + api "code.gitea.io/sdk/gitea" +) + +// swagger:response Organization +type swaggerResponseOrganization struct { + // in:body + Body api.Organization `json:"body"` +} + +// swagger:response OrganizationList +type swaggerResponseOrganizationList struct { + // in:body + Body []api.Organization `json:"body"` +} + +// swagger:response Team +type swaggerResponseTeam struct { + // in:body + Body api.Team `json:"body"` +} + +// swagger:response TeamList +type swaggerResponseTeamList struct { + // in:body + Body []api.Team `json:"body"` +} diff --git a/routers/api/v1/swagger/repo.go b/routers/api/v1/swagger/repo.go new file mode 100644 index 0000000000..703f7d18dd --- /dev/null +++ b/routers/api/v1/swagger/repo.go @@ -0,0 +1,92 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package swagger + +import ( + api "code.gitea.io/sdk/gitea" +) + +// swagger:response Repository +type swaggerResponseRepository struct { + // in:body + Body api.Repository `json:"body"` +} + +// swagger:response RepositoryList +type swaggerResponseRepositoryList struct { + // in:body + Body []api.Repository `json:"body"` +} + +// swagger:response Branch +type swaggerResponseBranch struct { + // in:body + Body api.Branch `json:"body"` +} + +// swagger:response BranchList +type swaggerResponseBranchList struct { + // in:body + Body []api.Branch `json:"body"` +} + +// swagger:response Hook +type swaggerResponseHook struct { + // in:body + Body []api.Branch `json:"body"` +} + +// swagger:response HookList +type swaggerResponseHookList struct { + // in:body + Body []api.Branch `json:"body"` +} + +// swagger:response Release +type swaggerResponseRelease struct { + // in:body + Body api.Release `json:"body"` +} + +// swagger:response ReleaseList +type swaggerResponseReleaseList struct { + // in:body + Body []api.Release `json:"body"` +} + +// swagger:response PullRequest +type swaggerResponsePullRequest struct { + // in:body + Body api.PullRequest `json:"body"` +} + +// swagger:response PullRequestList +type swaggerResponsePullRequestList struct { + // in:body + Body []api.PullRequest `json:"body"` +} + +// swagger:response Status +type swaggerResponseStatus struct { + // in:body + Body api.Status `json:"body"` +} + +// swagger:response StatusList +type swaggerResponseStatusList struct { + // in:body + Body []api.Status `json:"body"` +} + +// swagger:response WatchInfo +type swaggerResponseWatchInfo struct { + // in:body + Body api.WatchInfo `json:"body"` +} + +// swagger:response SearchResults +type swaggerResponseSearchResults struct { + Body api.SearchResults `json:"body"` +} diff --git a/routers/api/v1/swagger/user.go b/routers/api/v1/swagger/user.go new file mode 100644 index 0000000000..2bb8f1b76b --- /dev/null +++ b/routers/api/v1/swagger/user.go @@ -0,0 +1,33 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package swagger + +import ( + api "code.gitea.io/sdk/gitea" +) + +// swagger:response User +type swaggerResponseUser struct { + // in:body + Body api.User `json:"body"` +} + +// swagger:response UserList +type swaggerResponseUserList struct { + // in:body + Body []api.User `json:"body"` +} + +// swagger:response EmailList +type swaggerResponseEmailList struct { + // in:body + Body []api.Email `json:"body"` +} + +// swagger:model EditUserOption +type swaggerModelEditUserOption struct { + // in:body + Options api.EditUserOption +} diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go index 1d722e36e4..e1f75de683 100644 --- a/routers/api/v1/user/app.go +++ b/routers/api/v1/user/app.go @@ -13,15 +13,14 @@ import ( // ListAccessTokens list all the access tokens func ListAccessTokens(ctx *context.APIContext) { - // swagger:route GET /users/{username}/tokens user userGetTokens - // - // Produces: - // - application/json - // - // Responses: - // 200: AccessTokenList - // 500: error - + // swagger:operation GET /users/{username}/tokens user userGetTokens + // --- + // summary: List the authenticated user's access tokens + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/AccessTokenList" tokens, err := models.ListAccessTokens(ctx.User.ID) if err != nil { ctx.Error(500, "ListAccessTokens", err) @@ -40,18 +39,16 @@ func ListAccessTokens(ctx *context.APIContext) { // CreateAccessToken create access tokens func CreateAccessToken(ctx *context.APIContext, form api.CreateAccessTokenOption) { - // swagger:route POST /users/{username} /tokens user userCreateToken - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 200: AccessToken - // 500: error - + // swagger:operation POST /users/{username}/tokens user userCreateToken + // --- + // summary: Create an access token + // consumes: + // - application/json + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/AccessToken" t := &models.AccessToken{ UID: ctx.User.ID, Name: form.Name, diff --git a/routers/api/v1/user/email.go b/routers/api/v1/user/email.go index 0d83aa38c1..1d071e697f 100644 --- a/routers/api/v1/user/email.go +++ b/routers/api/v1/user/email.go @@ -13,9 +13,17 @@ import ( "code.gitea.io/gitea/routers/api/v1/convert" ) -// ListEmails list all the emails of mine +// ListEmails list all of the authenticated user's email addresses // see https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user func ListEmails(ctx *context.APIContext) { + // swagger:operation GET /user/emails user userListEmails + // --- + // summary: List the authenticated user's email addresses + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/EmailList" emails, err := models.GetEmailAddresses(ctx.User.ID) if err != nil { ctx.Error(500, "GetEmailAddresses", err) @@ -28,9 +36,26 @@ func ListEmails(ctx *context.APIContext) { ctx.JSON(200, &apiEmails) } -// AddEmail add email for me -// see https://github.com/gogits/go-gogs-client/wiki/Users-Emails#add-email-addresses +// AddEmail add an email address func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) { + // swagger:operation POST /user/emails user userAddEmail + // --- + // summary: Add email addresses + // produces: + // - application/json + // parameters: + // - name: options + // in: body + // schema: + // "$ref": "#/definitions/CreateEmailOption" + // parameters: + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateEmailOption" + // responses: + // '201': + // "$ref": "#/responses/EmailList" if len(form.Emails) == 0 { ctx.Status(422) return @@ -62,8 +87,20 @@ func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) { } // DeleteEmail delete email -// see https://github.com/gogits/go-gogs-client/wiki/Users-Emails#delete-email-addresses -func DeleteEmail(ctx *context.APIContext, form api.CreateEmailOption) { +func DeleteEmail(ctx *context.APIContext, form api.DeleteEmailOption) { + // swagger:operation DELETE /user/emails user userDeleteEmail + // --- + // summary: Delete email addresses + // produces: + // - application/json + // parameters: + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/DeleteEmailOption" + // responses: + // "204": + // "$ref": "#/responses/empty" if len(form.Emails) == 0 { ctx.Status(204) return diff --git a/routers/api/v1/user/follower.go b/routers/api/v1/user/follower.go index 55a0b032db..49d13cc380 100644 --- a/routers/api/v1/user/follower.go +++ b/routers/api/v1/user/follower.go @@ -28,31 +28,35 @@ func listUserFollowers(ctx *context.APIContext, u *models.User) { responseAPIUsers(ctx, users) } -// ListMyFollowers list all my followers +// ListMyFollowers list the authenticated user's followers func ListMyFollowers(ctx *context.APIContext) { - // swagger:route GET /user/followers user userCurrentListFollowers - // - // Produces: - // - application/json - // - // Responses: - // 200: UserList - // 500: error - + // swagger:operation GET /user/followers user userCurrentListFollowers + // --- + // summary: List the authenticated user's followers + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/UserList" listUserFollowers(ctx, ctx.User) } -// ListFollowers list user's followers +// ListFollowers list the given user's followers func ListFollowers(ctx *context.APIContext) { - // swagger:route GET /users/:username/followers user userListFollowers - // - // Produces: - // - application/json - // - // Responses: - // 200: UserList - // 500: error - + // swagger:operation GET /users/{username}/followers user userListFollowers + // --- + // summary: List the given user's followers + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of user + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/UserList" u := GetUserByParams(ctx) if ctx.Written() { return @@ -69,31 +73,35 @@ func listUserFollowing(ctx *context.APIContext, u *models.User) { responseAPIUsers(ctx, users) } -// ListMyFollowing list all my followings +// ListMyFollowing list the users that the authenticated user is following func ListMyFollowing(ctx *context.APIContext) { - // swagger:route GET /user/following user userCurrentListFollowing - // - // Produces: - // - application/json - // - // Responses: - // 200: UserList - // 500: error - + // swagger:operation GET /user/following user userCurrentListFollowing + // --- + // summary: List the users that the authenticated user is following + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/UserList" listUserFollowing(ctx, ctx.User) } -// ListFollowing list user's followings +// ListFollowing list the users that the given user is following func ListFollowing(ctx *context.APIContext) { - // swagger:route GET /users/{username}/following user userListFollowing - // - // Produces: - // - application/json - // - // Responses: - // 200: UserList - // 500: error - + // swagger:operation GET /users/{username}/following user userListFollowing + // --- + // summary: List the users that the given user is following + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of user + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/UserList" u := GetUserByParams(ctx) if ctx.Written() { return @@ -109,14 +117,22 @@ func checkUserFollowing(ctx *context.APIContext, u *models.User, followID int64) } } -// CheckMyFollowing check if the repo is followed by me +// CheckMyFollowing whether the given user is followed by the authenticated user func CheckMyFollowing(ctx *context.APIContext) { - // swagger:route GET /user/following/{username} user userCurrentCheckFollowing - // - // Responses: - // 204: empty - // 404: notFound - + // swagger:operation GET /user/following/{followee} user userCurrentCheckFollowing + // --- + // summary: Check whether a user is followed by the authenticated user + // parameters: + // - name: followee + // in: path + // description: username of followed user + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" + // "404": + // "$ref": "#/responses/notFound" target := GetUserByParams(ctx) if ctx.Written() { return @@ -124,14 +140,27 @@ func CheckMyFollowing(ctx *context.APIContext) { checkUserFollowing(ctx, ctx.User, target.ID) } -// CheckFollowing check if the repo is followed by user +// CheckFollowing check if one user is following another user func CheckFollowing(ctx *context.APIContext) { - // swagger:route GET /users/{username}/following/:target user userCheckFollowing - // - // Responses: - // 204: empty - // 404: notFound - + // swagger:operation GET /users/{follower}/following/{followee} user userCheckFollowing + // --- + // summary: Check if one user is following another user + // parameters: + // - name: follower + // in: path + // description: username of following user + // type: string + // required: true + // - name: followee + // in: path + // description: username of followed user + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" + // "404": + // "$ref": "#/responses/notFound" u := GetUserByParams(ctx) if ctx.Written() { return @@ -143,14 +172,20 @@ func CheckFollowing(ctx *context.APIContext) { checkUserFollowing(ctx, u, target.ID) } -// Follow follow one repository +// Follow follow a user func Follow(ctx *context.APIContext) { - // swagger:route PUT /user/following/{username} user userCurrentPutFollow - // - // Responses: - // 204: empty - // 500: error - + // swagger:operation PUT /user/following/{username} user userCurrentPutFollow + // --- + // summary: Follow a user + // parameters: + // - name: username + // in: path + // description: username of user to follow + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" target := GetUserByParams(ctx) if ctx.Written() { return @@ -162,14 +197,20 @@ func Follow(ctx *context.APIContext) { ctx.Status(204) } -// Unfollow unfollow one repository +// Unfollow unfollow a user func Unfollow(ctx *context.APIContext) { - // swagger:route DELETE /user/following/{username} user userCurrentDeleteFollow - // - // Responses: - // 204: empty - // 500: error - + // swagger:operation DELETE /user/following/{username} user userCurrentDeleteFollow + // --- + // summary: Unfollow a user + // parameters: + // - name: username + // in: path + // description: username of user to unfollow + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" target := GetUserByParams(ctx) if ctx.Written() { return diff --git a/routers/api/v1/user/gpg_key.go b/routers/api/v1/user/gpg_key.go index 96ff6e88ba..a955f3ff14 100644 --- a/routers/api/v1/user/gpg_key.go +++ b/routers/api/v1/user/gpg_key.go @@ -34,15 +34,20 @@ func listGPGKeys(ctx *context.APIContext, uid int64) { //ListGPGKeys get the GPG key list of a user func ListGPGKeys(ctx *context.APIContext) { - // swagger:route GET /users/{username}/gpg_keys user userListGPGKeys - // - // Produces: - // - application/json - // - // Responses: - // 200: GPGKeyList - // 500: error - + // swagger:operation GET /users/{username}/gpg_keys user userListGPGKeys + // --- + // summary: List the given user's GPG keys + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of user + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/GPGKeyList" user := GetUserByParams(ctx) if ctx.Written() { return @@ -50,32 +55,37 @@ func ListGPGKeys(ctx *context.APIContext) { listGPGKeys(ctx, user.ID) } -//ListMyGPGKeys get the GPG key list of the logged user +//ListMyGPGKeys get the GPG key list of the authenticated user func ListMyGPGKeys(ctx *context.APIContext) { - // swagger:route GET /user/gpg_keys user userCurrentListGPGKeys - // - // Produces: - // - application/json - // - // Responses: - // 200: GPGKeyList - // 500: error - + // swagger:operation GET /user/gpg_keys user userCurrentListGPGKeys + // --- + // summary: List the authenticated user's GPG keys + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/GPGKeyList" listGPGKeys(ctx, ctx.User.ID) } //GetGPGKey get the GPG key based on a id func GetGPGKey(ctx *context.APIContext) { - // swagger:route GET /user/gpg_keys/{id} user userCurrentGetGPGKey - // - // Produces: - // - application/json - // - // Responses: - // 200: GPGKey - // 404: notFound - // 500: error - + // swagger:operation GET /user/gpg_keys/{id} user userCurrentGetGPGKey + // --- + // summary: Get a GPG key + // produces: + // - application/json + // parameters: + // - name: id + // in: path + // description: id of key to get + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/GPGKey" + // "404": + // "$ref": "#/responses/notFound" key, err := models.GetGPGKeyByID(ctx.ParamsInt64(":id")) if err != nil { if models.IsErrGPGKeyNotExist(err) { @@ -98,36 +108,47 @@ func CreateUserGPGKey(ctx *context.APIContext, form api.CreateGPGKeyOption, uid ctx.JSON(201, convert.ToGPGKey(key)) } -//CreateGPGKey associate a GPG key to the current user -func CreateGPGKey(ctx *context.APIContext, form api.CreateGPGKeyOption) { - // swagger:route POST /user/gpg_keys user userCurrentPostGPGKey - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 201: GPGKey - // 422: validationError - // 500: error +// swagger:parameters userCurrentPostGPGKey +type swaggerUserCurrentPostGPGKey struct { + // in:body + Form api.CreateGPGKeyOption +} +//CreateGPGKey create a GPG key belonging to the authenticated user +func CreateGPGKey(ctx *context.APIContext, form api.CreateGPGKeyOption) { + // swagger:operation POST /user/gpg_keys user userCurrentPostGPGKey + // --- + // summary: Create a GPG key + // consumes: + // - application/json + // produces: + // - application/json + // responses: + // "201": + // "$ref": "#/responses/GPGKey" + // "422": + // "$ref": "#/responses/validationError" CreateUserGPGKey(ctx, form, ctx.User.ID) } -//DeleteGPGKey remove a GPG key associated to the current user +//DeleteGPGKey remove a GPG key belonging to the authenticated user func DeleteGPGKey(ctx *context.APIContext) { - // swagger:route DELETE /user/gpg_keys/{id} user userCurrentDeleteGPGKey - // - // Produces: - // - application/json - // - // Responses: - // 204: empty - // 403: forbidden - // 500: error - + // swagger:operation DELETE /user/gpg_keys/{id} user userCurrentDeleteGPGKey + // --- + // summary: Remove a GPG key + // produces: + // - application/json + // parameters: + // - name: id + // in: path + // description: id of key to delete + // type: integer + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" + // "403": + // "$ref": "#/responses/forbidden" if err := models.DeleteGPGKey(ctx.User, ctx.ParamsInt64(":id")); err != nil { if models.IsErrGPGKeyAccessDenied(err) { ctx.Error(403, "", "You do not have access to this key") @@ -144,9 +165,9 @@ func DeleteGPGKey(ctx *context.APIContext) { func HandleAddGPGKeyError(ctx *context.APIContext, err error) { switch { case models.IsErrGPGKeyAccessDenied(err): - ctx.Error(422, "", "You do not have access to this gpg key") + ctx.Error(422, "", "You do not have access to this GPG key") case models.IsErrGPGKeyIDAlreadyUsed(err): - ctx.Error(422, "", "A key with the same keyid is already in database") + ctx.Error(422, "", "A key with the same id already exists") default: ctx.Error(500, "AddGPGKey", err) } diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go index 1772ef4d25..3649dac9b9 100644 --- a/routers/api/v1/user/key.go +++ b/routers/api/v1/user/key.go @@ -53,31 +53,35 @@ func listPublicKeys(ctx *context.APIContext, uid int64) { ctx.JSON(200, &apiKeys) } -// ListMyPublicKeys list all my public keys +// ListMyPublicKeys list all of the authenticated user's public keys func ListMyPublicKeys(ctx *context.APIContext) { - // swagger:route GET /user/keys user userCurrentListKeys - // - // Produces: - // - application/json - // - // Responses: - // 200: PublicKeyList - // 500: error - + // swagger:operation GET /user/keys user userCurrentListKeys + // --- + // summary: List the authenticated user's public keys + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/PublicKeyList" listPublicKeys(ctx, ctx.User.ID) } -// ListPublicKeys list all user's public keys +// ListPublicKeys list the given user's public keys func ListPublicKeys(ctx *context.APIContext) { - // swagger:route GET /users/{username}/keys user userListKeys - // - // Produces: - // - application/json - // - // Responses: - // 200: PublicKeyList - // 500: error - + // swagger:operation GET /users/{username}/keys user userListKeys + // --- + // summary: List the given user's public keys + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of user + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/PublicKeyList" user := GetUserByParams(ctx) if ctx.Written() { return @@ -85,18 +89,24 @@ func ListPublicKeys(ctx *context.APIContext) { listPublicKeys(ctx, user.ID) } -// GetPublicKey get one public key +// GetPublicKey get a public key func GetPublicKey(ctx *context.APIContext) { - // swagger:route GET /user/keys/{id} user userCurrentGetKey - // - // Produces: - // - application/json - // - // Responses: - // 200: PublicKey - // 404: notFound - // 500: error - + // swagger:operation GET /user/keys/{id} user userCurrentGetKey + // --- + // summary: Get a public key + // produces: + // - application/json + // parameters: + // - name: id + // in: path + // description: id of key to get + // type: integer + // required: true + // responses: + // "200": + // "$ref": "#/responses/PublicKey" + // "404": + // "$ref": "#/responses/notFound" key, err := models.GetPublicKeyByID(ctx.ParamsInt64(":id")) if err != nil { if models.IsErrKeyNotExist(err) { @@ -130,34 +140,44 @@ func CreateUserPublicKey(ctx *context.APIContext, form api.CreateKeyOption, uid // CreatePublicKey create one public key for me func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) { - // swagger:route POST /user/keys user userCurrentPostKey - // - // Consumes: - // - application/json - // - // Produces: - // - application/json - // - // Responses: - // 201: PublicKey - // 422: validationError - // 500: error - + // swagger:operation POST /user/keys user userCurrentPostKey + // --- + // summary: Create a public key + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/CreateKeyOption" + // responses: + // "201": + // "$ref": "#/responses/PublicKey" + // "422": + // "$ref": "#/responses/validationError" CreateUserPublicKey(ctx, form, ctx.User.ID) } -// DeletePublicKey delete one public key of mine +// DeletePublicKey delete one public key func DeletePublicKey(ctx *context.APIContext) { - // swagger:route DELETE /user/keys/{id} user userCurrentDeleteKey - // - // Produces: - // - application/json - // - // Responses: - // 204: empty - // 403: forbidden - // 500: error - + // swagger:operation DELETE /user/keys/{id} user userCurrentDeleteKey + // --- + // summary: Delete a public key + // produces: + // - application/json + // parameters: + // - name: id + // in: path + // description: id of key to delete + // type: integer + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" + // "403": + // "$ref": "#/responses/forbidden" if err := models.DeletePublicKey(ctx.User, ctx.ParamsInt64(":id")); err != nil { if models.IsErrKeyAccessDenied(err) { ctx.Error(403, "", "You do not have access to this key") diff --git a/routers/api/v1/user/repo.go b/routers/api/v1/user/repo.go index f119632e39..38fe76cad4 100644 --- a/routers/api/v1/user/repo.go +++ b/routers/api/v1/user/repo.go @@ -36,15 +36,20 @@ func listUserRepos(ctx *context.APIContext, u *models.User) { // ListUserRepos - list the repos owned by the given user. func ListUserRepos(ctx *context.APIContext) { - // swagger:route GET /users/{username}/repos user userListRepos - // - // Produces: - // - application/json - // - // Responses: - // 200: RepositoryList - // 500: error - + // swagger:operation GET /users/{username}/repos user userListRepos + // --- + // summary: List the repos owned by the given user + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of user + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/RepositoryList" user := GetUserByParams(ctx) if ctx.Written() { return @@ -54,14 +59,14 @@ func ListUserRepos(ctx *context.APIContext) { // ListMyRepos - list the repositories you own or have access to. func ListMyRepos(ctx *context.APIContext) { - // swagger:route GET /user/repos user userCurrentListRepos - // - // Produces: - // - application/json - // - // Responses: - // 200: RepositoryList - // 500: error + // swagger:operation GET /user/repos user userCurrentListRepos + // --- + // summary: List the repos that the authenticated user owns or has access to + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/RepositoryList" ownRepos, err := models.GetUserRepositories(ctx.User.ID, true, 1, ctx.User.NumRepos, "") if err != nil { ctx.Error(500, "GetUserRepositories", err) @@ -87,14 +92,19 @@ func ListMyRepos(ctx *context.APIContext) { // ListOrgRepos - list the repositories of an organization. func ListOrgRepos(ctx *context.APIContext) { - // swagger:route GET /orgs/{orgname}/repos organization orgListRepos - // - // Produces: - // - application/json - // - // Responses: - // 200: RepositoryList - // 500: error - + // swagger:operation GET /orgs/{org}/repos organization orgListRepos + // --- + // summary: List an organization's repos + // produces: + // - application/json + // parameters: + // - name: org + // in: path + // description: name of the organization + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/RepositoryList" listUserRepos(ctx, ctx.Org.Organization) } diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go index 6f943a2712..1cf4f5239c 100644 --- a/routers/api/v1/user/star.go +++ b/routers/api/v1/user/star.go @@ -30,18 +30,22 @@ func getStarredRepos(userID int64, private bool) ([]*api.Repository, error) { return repos, nil } -// GetStarredRepos returns the repos that the user specified by the APIContext -// has starred +// GetStarredRepos returns the repos that the given user has starred func GetStarredRepos(ctx *context.APIContext) { - // swagger:route GET /users/{username}/starred user userListStarred - // - // Produces: - // - application/json - // - // Responses: - // 200: RepositoryList - // 500: error - + // swagger:operation GET /users/{username}/starred user userListStarred + // --- + // summary: The repos that the given user has starred + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of user + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/RepositoryList" user := GetUserByParams(ctx) private := user.ID == ctx.User.ID repos, err := getStarredRepos(user.ID, private) @@ -53,15 +57,14 @@ func GetStarredRepos(ctx *context.APIContext) { // GetMyStarredRepos returns the repos that the authenticated user has starred func GetMyStarredRepos(ctx *context.APIContext) { - // swagger:route GET /user/starred user userCurrentListStarred - // - // Produces: - // - application/json - // - // Responses: - // 200: RepositoryList - // 500: error - + // swagger:operation GET /user/starred user userCurrentListStarred + // --- + // summary: The repos that the authenticated user has starred + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/RepositoryList" repos, err := getStarredRepos(ctx.User.ID, true) if err != nil { ctx.Error(500, "getStarredRepos", err) @@ -71,12 +74,25 @@ func GetMyStarredRepos(ctx *context.APIContext) { // IsStarring returns whether the authenticated is starring the repo func IsStarring(ctx *context.APIContext) { - // swagger:route GET /user/starred/{username}/{reponame} user userCurrentCheckStarring - // - // Responses: - // 204: empty - // 404: notFound - + // swagger:operation GET /user/starred/{owner}/{repo} user userCurrentCheckStarring + // --- + // summary: Whether the authenticated is starring the repo + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" + // "404": + // "$ref": "#/responses/notFound" if models.IsStaring(ctx.User.ID, ctx.Repo.Repository.ID) { ctx.Status(204) } else { @@ -86,12 +102,23 @@ func IsStarring(ctx *context.APIContext) { // Star the repo specified in the APIContext, as the authenticated user func Star(ctx *context.APIContext) { - // swagger:route PUT /user/starred/{username}/{reponame} user userCurrentPutStar - // - // Responses: - // 204: empty - // 500: error - + // swagger:operation PUT /user/starred/{owner}/{repo} user userCurrentPutStar + // --- + // summary: Star the given repo + // parameters: + // - name: owner + // in: path + // description: owner of the repo to star + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo to star + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" err := models.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, true) if err != nil { ctx.Error(500, "StarRepo", err) @@ -102,12 +129,23 @@ func Star(ctx *context.APIContext) { // Unstar the repo specified in the APIContext, as the authenticated user func Unstar(ctx *context.APIContext) { - // swagger:route DELETE /user/starred/{username}/{reponame} user userCurrentDeleteStar - // - // Responses: - // 204: empty - // 500: error - + // swagger:operation DELETE /user/starred/{owner}/{repo} user userCurrentDeleteStar + // --- + // summary: Unstar the given repo + // parameters: + // - name: owner + // in: path + // description: owner of the repo to unstar + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo to unstar + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" err := models.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, false) if err != nil { ctx.Error(500, "StarRepo", err) diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index 799cec0804..0453a455f4 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -17,15 +17,23 @@ import ( // Search search users func Search(ctx *context.APIContext) { - // swagger:route GET /users/search user userSearch - // - // Produces: - // - application/json - // - // Responses: - // 200: UserList - // 500: error - + // swagger:operation GET /users/search user userSearch + // --- + // summary: Search for users + // produces: + // - application/json + // parameters: + // - name: q + // in: query + // description: keyword + // type: string + // - name: limit + // in: query + // description: maximum number of users to return + // type: integer + // responses: + // "200": + // "$ref": "#/responses/UserList" opts := &models.SearchUserOptions{ Keyword: strings.Trim(ctx.Query("q"), " "), Type: models.UserTypeIndividual, @@ -65,16 +73,22 @@ func Search(ctx *context.APIContext) { // GetInfo get user's information func GetInfo(ctx *context.APIContext) { - // swagger:route GET /users/{username} user userGet - // - // Produces: - // - application/json - // - // Responses: - // 200: User - // 404: notFound - // 500: error - + // swagger:operation GET /users/{username} user userGet + // --- + // summary: Get a user + // produces: + // - application/json + // parameters: + // - name: username + // in: path + // description: username of user to get + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/User" + // "404": + // "$ref": "#/responses/notFound" u, err := models.GetUserByName(ctx.Params(":username")) if err != nil { if models.IsErrUserNotExist(err) { @@ -92,15 +106,15 @@ func GetInfo(ctx *context.APIContext) { ctx.JSON(200, u.APIFormat()) } -// GetAuthenticatedUser get curent user's information +// GetAuthenticatedUser get current user's information func GetAuthenticatedUser(ctx *context.APIContext) { - // swagger:route GET /user user userGetCurrent - // - // Produces: - // - application/json - // - // Responses: - // 200: User - + // swagger:operation GET /user user userGetCurrent + // --- + // summary: Get the authenticated user + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/User" ctx.JSON(200, ctx.User.APIFormat()) } diff --git a/routers/api/v1/user/watch.go b/routers/api/v1/user/watch.go index 18628c91d1..b10831f5f2 100644 --- a/routers/api/v1/user/watch.go +++ b/routers/api/v1/user/watch.go @@ -33,15 +33,19 @@ func getWatchedRepos(userID int64, private bool) ([]*api.Repository, error) { // GetWatchedRepos returns the repos that the user specified in ctx is watching func GetWatchedRepos(ctx *context.APIContext) { - // swagger:route GET /users/{username}/subscriptions user userListSubscriptions - // - // Produces: - // - application/json - // - // Responses: - // 200: RepositoryList - // 500: error - + // swagger:operation GET /users/{username}/subscriptions user userListSubscriptions + // --- + // summary: List the repositories watched by a user + // produces: + // - application/json + // parameters: + // - name: username + // type: string + // in: path + // description: username of the user + // responses: + // "200": + // "$ref": "#/responses/RepositoryList" user := GetUserByParams(ctx) private := user.ID == ctx.User.ID repos, err := getWatchedRepos(user.ID, private) @@ -53,15 +57,14 @@ func GetWatchedRepos(ctx *context.APIContext) { // GetMyWatchedRepos returns the repos that the authenticated user is watching func GetMyWatchedRepos(ctx *context.APIContext) { - // swagger:route GET /user/subscriptions user userCurrentListSubscriptions - // - // Produces: - // - application/json - // - // Responses: - // 200: RepositoryList - // 500: error - + // swagger:operation GET /user/subscriptions user userCurrentListSubscriptions + // --- + // summary: List repositories watched by the authenticated user + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/RepositoryList" repos, err := getWatchedRepos(ctx.User.ID, true) if err != nil { ctx.Error(500, "getWatchedRepos", err) @@ -72,12 +75,23 @@ func GetMyWatchedRepos(ctx *context.APIContext) { // IsWatching returns whether the authenticated user is watching the repo // specified in ctx func IsWatching(ctx *context.APIContext) { - // swagger:route GET /repos/{username}/{reponame}/subscription repository userCurrentCheckSubscription - // - // Responses: - // 200: WatchInfo - // 404: notFound - + // swagger:operation GET /repos/{owner}/{repo}/subscription repository userCurrentCheckSubscription + // --- + // summary: Check if the current user is watching a repo + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/WatchInfo" if models.IsWatching(ctx.User.ID, ctx.Repo.Repository.ID) { ctx.JSON(200, api.WatchInfo{ Subscribed: true, @@ -94,12 +108,23 @@ func IsWatching(ctx *context.APIContext) { // Watch the repo specified in ctx, as the authenticated user func Watch(ctx *context.APIContext) { - // swagger:route PUT /repos/{username}/{reponame}/subscription repository userCurrentPutSubscription - // - // Responses: - // 200: WatchInfo - // 500: error - + // swagger:operation PUT /repos/{owner}/{repo}/subscription repository userCurrentPutSubscription + // --- + // summary: Watch a repo + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/WatchInfo" err := models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, true) if err != nil { ctx.Error(500, "WatchRepo", err) @@ -118,12 +143,23 @@ func Watch(ctx *context.APIContext) { // Unwatch the repo specified in ctx, as the authenticated user func Unwatch(ctx *context.APIContext) { - // swagger:route DELETE /repos/{username}/{reponame}/subscription repository userCurrentDeleteSubscription - // - // Responses: - // 204: empty - // 500: error - + // swagger:operation DELETE /repos/{owner}/{repo}/subscription repository userCurrentDeleteSubscription + // --- + // summary: Unwatch a repo + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "204": + // "$ref": "#/responses/empty" err := models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, false) if err != nil { ctx.Error(500, "UnwatchRepo", err) diff --git a/vendor/code.gitea.io/sdk/gitea/admin_user.go b/vendor/code.gitea.io/sdk/gitea/admin_user.go index 74f166a4f4..6d736d3462 100644 --- a/vendor/code.gitea.io/sdk/gitea/admin_user.go +++ b/vendor/code.gitea.io/sdk/gitea/admin_user.go @@ -11,21 +11,17 @@ import ( ) // CreateUserOption create user options -// swagger:parameters adminCreateUser type CreateUserOption struct { - // in: body SourceID int64 `json:"source_id"` - // in: body LoginName string `json:"login_name"` - // in: body + // required: true Username string `json:"username" binding:"Required;AlphaDashDot;MaxSize(35)"` - // in: body FullName string `json:"full_name" binding:"MaxSize(100)"` - // in: body + // required: true + // swagger:strfmt email Email string `json:"email" binding:"Required;Email;MaxSize(254)"` - // in: body - Password string `json:"password" binding:"MaxSize(255)"` - // in: body + // required: true + Password string `json:"password" binding:"Required;MaxSize(255)"` SendNotify bool `json:"send_notify"` } @@ -40,31 +36,20 @@ func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error) { } // EditUserOption edit user options -// swagger:parameters adminEditUser type EditUserOption struct { - // in: body SourceID int64 `json:"source_id"` - // in: body LoginName string `json:"login_name"` - // in: body FullName string `json:"full_name" binding:"MaxSize(100)"` - // in: body + // required: true + // swagger:strfmt email Email string `json:"email" binding:"Required;Email;MaxSize(254)"` - // in: body Password string `json:"password" binding:"MaxSize(255)"` - // in: body Website string `json:"website" binding:"MaxSize(50)"` - // in: body Location string `json:"location" binding:"MaxSize(50)"` - // in: body Active *bool `json:"active"` - // in: body Admin *bool `json:"admin"` - // in: body AllowGitHook *bool `json:"allow_git_hook"` - // in: body AllowImportLocal *bool `json:"allow_import_local"` - // in: body MaxRepoCreation *int `json:"max_repo_creation"` } diff --git a/vendor/code.gitea.io/sdk/gitea/attachment.go b/vendor/code.gitea.io/sdk/gitea/attachment.go new file mode 100644 index 0000000000..10e7a1d56a --- /dev/null +++ b/vendor/code.gitea.io/sdk/gitea/attachment.go @@ -0,0 +1,17 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package gitea // import "code.gitea.io/sdk/gitea" +import "time" + +// Attachment a generic attachment +type Attachment struct { + ID int64 `json:"id"` + Name string `json:"name"` + Size int64 `json:"size"` + DownloadCount int64 `json:"download_count"` + Created time.Time `json:"created_at"` + UUID string `json:"uuid"` + DownloadURL string `json:"browser_download_url"` +} diff --git a/vendor/code.gitea.io/sdk/gitea/fork.go b/vendor/code.gitea.io/sdk/gitea/fork.go index aa523ab174..57222498ef 100644 --- a/vendor/code.gitea.io/sdk/gitea/fork.go +++ b/vendor/code.gitea.io/sdk/gitea/fork.go @@ -20,9 +20,8 @@ func (c *Client) ListForks(user, repo string) ([]*Repository, error) { } // CreateForkOption options for creating a fork -// swagger:parameters createFork type CreateForkOption struct { - // in: body + // organization name, if forking into an organization Organization *string `json:"organization"` } diff --git a/vendor/code.gitea.io/sdk/gitea/hook.go b/vendor/code.gitea.io/sdk/gitea/hook.go index c0beb271bd..b7109482f8 100644 --- a/vendor/code.gitea.io/sdk/gitea/hook.go +++ b/vendor/code.gitea.io/sdk/gitea/hook.go @@ -20,7 +20,6 @@ var ( ) // Hook a hook is a web hook when one repository changed -// swagger:response Hook type Hook struct { ID int64 `json:"id"` Type string `json:"type"` @@ -28,12 +27,13 @@ type Hook struct { Config map[string]string `json:"config"` Events []string `json:"events"` Active bool `json:"active"` + // swagger:strfmt date-time Updated time.Time `json:"updated_at"` + // swagger:strfmt date-time Created time.Time `json:"created_at"` } // HookList represents a list of API hook. -// swagger:response HookList type HookList []*Hook // ListOrgHooks list all the hooks of one organization @@ -61,15 +61,14 @@ func (c *Client) GetRepoHook(user, repo string, id int64) (*Hook, error) { } // CreateHookOption options when create a hook -// swagger:parameters orgCreateHook repoCreateHook type CreateHookOption struct { - // in: body + // required: true + // enum: gitea,gogs,slack,discord Type string `json:"type" binding:"Required"` - // in: body + // required: true Config map[string]string `json:"config" binding:"Required"` - // in: body Events []string `json:"events"` - // in: body + // default: false Active bool `json:"active"` } @@ -94,13 +93,9 @@ func (c *Client) CreateRepoHook(user, repo string, opt CreateHookOption) (*Hook, } // EditHookOption options when modify one hook -// swagger:parameters orgEditHook repoEditHook type EditHookOption struct { - // in: body Config map[string]string `json:"config"` - // in: body Events []string `json:"events"` - // in: body Active *bool `json:"active"` } @@ -142,25 +137,32 @@ type Payloader interface { JSONPayload() ([]byte, error) } -// PayloadUser FIXME +// PayloadUser represents the author or committer of a commit type PayloadUser struct { + // Full name of the commit author Name string `json:"name"` + // swagger:strfmt email Email string `json:"email"` UserName string `json:"username"` } -// PayloadCommit FIXME: consider use same format as API when commits API are added. +// FIXME: consider using same format as API when commits API are added. +// applies to PayloadCommit and PayloadCommitVerification + +// PayloadCommit represents a commit type PayloadCommit struct { + // sha1 hash of the commit ID string `json:"id"` Message string `json:"message"` URL string `json:"url"` Author *PayloadUser `json:"author"` Committer *PayloadUser `json:"committer"` Verification *PayloadCommitVerification `json:"verification"` + // swagger:strfmt date-time Timestamp time.Time `json:"timestamp"` } -// PayloadCommitVerification represent the GPG verification part of a commit. FIXME: like PayloadCommit consider use same format as API when commits API are added. +// PayloadCommitVerification represents the GPG verification of a commit type PayloadCommitVerification struct { Verified bool `json:"verified"` Reason string `json:"reason"` diff --git a/vendor/code.gitea.io/sdk/gitea/issue.go b/vendor/code.gitea.io/sdk/gitea/issue.go index 729e54fe8b..720f54caae 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue.go +++ b/vendor/code.gitea.io/sdk/gitea/issue.go @@ -27,7 +27,8 @@ type PullRequestMeta struct { Merged *time.Time `json:"merged_at"` } -// Issue an issue to a repository +// Issue represents an issue in a repository +// swagger:model type Issue struct { ID int64 `json:"id"` URL string `json:"url"` @@ -38,9 +39,15 @@ type Issue struct { Labels []*Label `json:"labels"` Milestone *Milestone `json:"milestone"` Assignee *User `json:"assignee"` + // Whether the issue is open or closed + // + // type: string + // enum: open,closed State StateType `json:"state"` Comments int `json:"comments"` + // swagger:strfmt date-time Created time.Time `json:"created_at"` + // swagger:strfmt date-time Updated time.Time `json:"updated_at"` PullRequest *PullRequestMeta `json:"pull_request"` @@ -78,10 +85,14 @@ func (c *Client) GetIssue(owner, repo string, index int64) (*Issue, error) { // CreateIssueOption options to create one issue type CreateIssueOption struct { + // required:true Title string `json:"title" binding:"Required"` Body string `json:"body"` + // username of assignee Assignee string `json:"assignee"` + // milestone id Milestone int64 `json:"milestone"` + // list of label ids Labels []int64 `json:"labels"` Closed bool `json:"closed"` } @@ -97,7 +108,7 @@ func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue, jsonHeader, bytes.NewReader(body), issue) } -// EditIssueOption edit issue options +// EditIssueOption options for editing an issue type EditIssueOption struct { Title string `json:"title"` Body *string `json:"body"` diff --git a/vendor/code.gitea.io/sdk/gitea/issue_comment.go b/vendor/code.gitea.io/sdk/gitea/issue_comment.go index 0977f98a4a..f146c1fe2d 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_comment.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_comment.go @@ -11,7 +11,7 @@ import ( "time" ) -// Comment represents a comment in commit and issue page. +// Comment represents a comment on a commit or issue type Comment struct { ID int64 `json:"id"` HTMLURL string `json:"html_url"` @@ -19,7 +19,9 @@ type Comment struct { IssueURL string `json:"issue_url"` Poster *User `json:"user"` Body string `json:"body"` + // swagger:strfmt date-time Created time.Time `json:"created_at"` + // swagger:strfmt date-time Updated time.Time `json:"updated_at"` } @@ -35,8 +37,9 @@ func (c *Client) ListRepoIssueComments(owner, repo string) ([]*Comment, error) { return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo), nil, nil, &comments) } -// CreateIssueCommentOption is option when creating an issue comment. +// CreateIssueCommentOption options for creating a comment on an issue type CreateIssueCommentOption struct { + // required:true Body string `json:"body" binding:"Required"` } @@ -50,8 +53,9 @@ func (c *Client) CreateIssueComment(owner, repo string, index int64, opt CreateI return comment, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), jsonHeader, bytes.NewReader(body), comment) } -// EditIssueCommentOption is option when editing an issue comment. +// EditIssueCommentOption options for editing a comment type EditIssueCommentOption struct { + // required: true Body string `json:"body" binding:"Required"` } diff --git a/vendor/code.gitea.io/sdk/gitea/issue_label.go b/vendor/code.gitea.io/sdk/gitea/issue_label.go index 20607f2efd..3acf1440b4 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_label.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_label.go @@ -11,14 +11,16 @@ import ( ) // Label a label to an issue or a pr +// swagger:model type Label struct { ID int64 `json:"id"` Name string `json:"name"` + // example: 00aabb Color string `json:"color"` URL string `json:"url"` } -// ListRepoLabels list lables of one reppsitory +// ListRepoLabels list labels of one repository func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) { labels := make([]*Label, 0, 10) return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), nil, nil, &labels) @@ -31,9 +33,12 @@ func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, error) { return label, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil, label) } -// CreateLabelOption create options when one label of repository +// CreateLabelOption options for creating a label type CreateLabelOption struct { + // required:true Name string `json:"name" binding:"Required"` + // required:true + // example: #00aabb Color string `json:"color" binding:"Required;Size(7)"` } @@ -48,7 +53,7 @@ func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label, jsonHeader, bytes.NewReader(body), label) } -// EditLabelOption edit label options +// EditLabelOption options for editing a label type EditLabelOption struct { Name *string `json:"name"` Color *string `json:"color"` @@ -71,8 +76,9 @@ func (c *Client) DeleteLabel(owner, repo string, id int64) error { return err } -// IssueLabelsOption list one issue's labels options +// IssueLabelsOption a collection of labels type IssueLabelsOption struct { + // list of label IDs Labels []int64 `json:"labels"` } diff --git a/vendor/code.gitea.io/sdk/gitea/issue_milestone.go b/vendor/code.gitea.io/sdk/gitea/issue_milestone.go index e35325e8d6..d820067422 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_milestone.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_milestone.go @@ -19,7 +19,9 @@ type Milestone struct { State StateType `json:"state"` OpenIssues int `json:"open_issues"` ClosedIssues int `json:"closed_issues"` + // swagger:strfmt date-time Closed *time.Time `json:"closed_at"` + // swagger:strfmt date-time Deadline *time.Time `json:"due_on"` } @@ -35,10 +37,11 @@ func (c *Client) GetMilestone(owner, repo string, id int64) (*Milestone, error) return milestone, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil, milestone) } -// CreateMilestoneOption options when creating milestone +// CreateMilestoneOption options for creating a milestone type CreateMilestoneOption struct { Title string `json:"title"` Description string `json:"description"` + // swagger:strfmt date-time Deadline *time.Time `json:"due_on"` } @@ -52,7 +55,7 @@ func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption) return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), jsonHeader, bytes.NewReader(body), milestone) } -// EditMilestoneOption options when modify milestone +// EditMilestoneOption options for editing a milestone type EditMilestoneOption struct { Title string `json:"title"` Description *string `json:"description"` diff --git a/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go b/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go index 67b8a9b613..dcdecbb2a2 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go @@ -12,9 +12,9 @@ import ( ) // TrackedTime worked time for an issue / pr -// swagger:response TrackedTime type TrackedTime struct { ID int64 `json:"id"` + // swagger:strfmt date-time Created time.Time `json:"created"` // Time in seconds Time int64 `json:"time"` @@ -23,7 +23,6 @@ type TrackedTime struct { } // TrackedTimes represent a list of tracked times -// swagger:response TrackedTimes type TrackedTimes []*TrackedTime // GetUserTrackedTimes list tracked times of a user @@ -44,10 +43,10 @@ func (c *Client) GetMyTrackedTimes() (TrackedTimes, error) { return times, c.getParsedResponse("GET", "/user/times", nil, nil, ×) } -// AddTimeOption adds time manually to an issue -// swagger:parameters addTime +// AddTimeOption options for adding time to an issue type AddTimeOption struct { - // in: body + // time in seconds + // required: true Time int64 `json:"time" binding:"Required"` } diff --git a/vendor/code.gitea.io/sdk/gitea/miscellaneous.go b/vendor/code.gitea.io/sdk/gitea/miscellaneous.go index be1aa5e8b0..3735047b7f 100644 --- a/vendor/code.gitea.io/sdk/gitea/miscellaneous.go +++ b/vendor/code.gitea.io/sdk/gitea/miscellaneous.go @@ -4,22 +4,19 @@ package gitea -// SearchResults results of search -// swagger:response SearchResults +// SearchResults results of a successful search type SearchResults struct { OK bool `json:"ok"` Data []*Repository `json:"data"` } -// SearchError error of failing search -// swagger:response SearchError +// SearchError error of a failed search type SearchError struct { OK bool `json:"ok"` Error string `json:"error"` } // MarkdownOption markdown options -// swagger:parameters renderMarkdown type MarkdownOption struct { // Text markdown to render // @@ -44,9 +41,8 @@ type MarkdownOption struct { type MarkdownRender string // ServerVersion wraps the version of the server -// swagger:response ServerVersion type ServerVersion struct { - Version string + Version string `json:"version"` } // ServerVersion returns the version of the server diff --git a/vendor/code.gitea.io/sdk/gitea/org.go b/vendor/code.gitea.io/sdk/gitea/org.go index ffdc2ffbea..d67d707e7b 100644 --- a/vendor/code.gitea.io/sdk/gitea/org.go +++ b/vendor/code.gitea.io/sdk/gitea/org.go @@ -10,8 +10,7 @@ import ( "fmt" ) -// Organization a group of some repositories, users and teams -// swagger:response Organization +// Organization represents an organization type Organization struct { ID int64 `json:"id"` UserName string `json:"username"` @@ -40,22 +39,17 @@ func (c *Client) GetOrg(orgname string) (*Organization, error) { return org, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s", orgname), nil, nil, org) } -// CreateOrgOption create one organization options -// swagger:parameters adminCreateOrg +// CreateOrgOption options for creating an organization type CreateOrgOption struct { - // in: body + // required: true UserName string `json:"username" binding:"Required"` - // in: body FullName string `json:"full_name"` - // in: body Description string `json:"description"` - // in: body Website string `json:"website"` - // in: body Location string `json:"location"` } -// EditOrgOption edit one organization options +// EditOrgOption options for editing an organization type EditOrgOption struct { FullName string `json:"full_name"` Description string `json:"description"` diff --git a/vendor/code.gitea.io/sdk/gitea/org_team.go b/vendor/code.gitea.io/sdk/gitea/org_team.go index eddaa2d60e..0c9a740350 100644 --- a/vendor/code.gitea.io/sdk/gitea/org_team.go +++ b/vendor/code.gitea.io/sdk/gitea/org_team.go @@ -4,24 +4,29 @@ package gitea -// Team is a sub virtual organization of one Organization +// Team represents a team in an organization type Team struct { ID int64 `json:"id"` Name string `json:"name"` Description string `json:"description"` + // enum: none,read,write,admin,owner Permission string `json:"permission"` } -// CreateTeamOption options when create team +// CreateTeamOption options for creating a team type CreateTeamOption struct { + // required: true Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` Description string `json:"description" binding:"MaxSize(255)"` + // enum: read,write,admin Permission string `json:"permission"` } -// EditTeamOption options when edit team +// EditTeamOption options for editing a team type EditTeamOption struct { + // required: true Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` Description string `json:"description" binding:"MaxSize(255)"` + // enum: read,write,admin Permission string `json:"permission"` } diff --git a/vendor/code.gitea.io/sdk/gitea/pull.go b/vendor/code.gitea.io/sdk/gitea/pull.go index a50db96e3e..0aa0ea8cc1 100644 --- a/vendor/code.gitea.io/sdk/gitea/pull.go +++ b/vendor/code.gitea.io/sdk/gitea/pull.go @@ -11,7 +11,7 @@ import ( "time" ) -// PullRequest represents a pull request API object. +// PullRequest represents a pull request type PullRequest struct { ID int64 `json:"id"` URL string `json:"url"` @@ -31,6 +31,7 @@ type PullRequest struct { Mergeable bool `json:"mergeable"` HasMerged bool `json:"merged"` + // swagger:strfmt date-time Merged *time.Time `json:"merged_at"` MergedCommitID *string `json:"merge_commit_sha"` MergedBy *User `json:"merged_by"` @@ -39,11 +40,13 @@ type PullRequest struct { Head *PRBranchInfo `json:"head"` MergeBase string `json:"merge_base"` + // swagger:strfmt date-time Created *time.Time `json:"created_at"` + // swagger:strfmt date-time Updated *time.Time `json:"updated_at"` } -// PRBranchInfo base branch info when send a PR +// PRBranchInfo information about a branch type PRBranchInfo struct { Name string `json:"label"` Ref string `json:"ref"` @@ -52,7 +55,7 @@ type PRBranchInfo struct { Repository *Repository `json:"repo"` } -// ListPullRequestsOptions options when list PRs +// ListPullRequestsOptions options for listing pull requests type ListPullRequestsOptions struct { Page int `json:"page"` State string `json:"state"` diff --git a/vendor/code.gitea.io/sdk/gitea/release.go b/vendor/code.gitea.io/sdk/gitea/release.go index cc841466d8..01e41e35a6 100644 --- a/vendor/code.gitea.io/sdk/gitea/release.go +++ b/vendor/code.gitea.io/sdk/gitea/release.go @@ -23,7 +23,9 @@ type Release struct { ZipURL string `json:"zipball_url"` IsDraft bool `json:"draft"` IsPrerelease bool `json:"prerelease"` + // swagger:strfmt date-time CreatedAt time.Time `json:"created_at"` + // swagger:strfmt date-time PublishedAt time.Time `json:"published_at"` Publisher *User `json:"author"` } @@ -48,6 +50,7 @@ func (c *Client) GetRelease(user, repo string, id int64) (*Release, error) { // CreateReleaseOption options when creating a release type CreateReleaseOption struct { + // required: true TagName string `json:"tag_name" binding:"Required"` Target string `json:"target_commitish"` Title string `json:"name"` diff --git a/vendor/code.gitea.io/sdk/gitea/repo.go b/vendor/code.gitea.io/sdk/gitea/repo.go index 5b4673d034..3def6e26ce 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo.go +++ b/vendor/code.gitea.io/sdk/gitea/repo.go @@ -11,15 +11,14 @@ import ( "time" ) -// Permission represents a API permission. +// Permission represents a set of permissions type Permission struct { Admin bool `json:"admin"` Push bool `json:"push"` Pull bool `json:"pull"` } -// Repository represents a API repository. -// swagger:response Repository +// Repository represents a repository type Repository struct { ID int64 `json:"id"` Owner *User `json:"owner"` @@ -41,15 +40,13 @@ type Repository struct { Watchers int `json:"watchers_count"` OpenIssues int `json:"open_issues_count"` DefaultBranch string `json:"default_branch"` + // swagger:strfmt date-time Created time.Time `json:"created_at"` + // swagger:strfmt date-time Updated time.Time `json:"updated_at"` Permissions *Permission `json:"permissions,omitempty"` } -// RepositoryList represents a list of API repository. -// swagger:response RepositoryList -type RepositoryList []*Repository - // ListMyRepos lists all repositories for the authenticated user that has access to. func (c *Client) ListMyRepos() ([]*Repository, error) { repos := make([]*Repository, 0, 10) @@ -69,36 +66,24 @@ func (c *Client) ListOrgRepos(org string) ([]*Repository, error) { } // CreateRepoOption options when creating repository -//swagger:parameters createOrgRepo adminCreateRepo createCurrentUserRepo +// swagger:model type CreateRepoOption struct { // Name of the repository to create // - // in: body + // required: true // unique: true Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"` // Description of the repository to create - // - // in: body Description string `json:"description" binding:"MaxSize(255)"` - // Is the repository to create private ? - // - // in: body + // Whether the repository is private Private bool `json:"private"` - // Init the repository to create ? - // - // in: body + // Whether the repository should be auto-intialized? AutoInit bool `json:"auto_init"` // Gitignores to use - // - // in: body Gitignores string `json:"gitignores"` // License to use - // - // in: body License string `json:"license"` // Readme of the repository to create - // - // in: body Readme string `json:"readme"` } @@ -134,24 +119,18 @@ func (c *Client) DeleteRepo(owner, repo string) error { return err } -// MigrateRepoOption options when migrate repository from an external place -// swagger:parameters repoMigrate +// MigrateRepoOption options for migrating a repository from an external service type MigrateRepoOption struct { - // in: body + // required: true CloneAddr string `json:"clone_addr" binding:"Required"` - // in: body AuthUsername string `json:"auth_username"` - // in: body AuthPassword string `json:"auth_password"` - // in: body + // required: true UID int `json:"uid" binding:"Required"` - // in: body + // required: true RepoName string `json:"repo_name" binding:"Required"` - // in: body Mirror bool `json:"mirror"` - // in: body Private bool `json:"private"` - // in: body Description string `json:"description"` } diff --git a/vendor/code.gitea.io/sdk/gitea/repo_branch.go b/vendor/code.gitea.io/sdk/gitea/repo_branch.go index fadc9e3956..481fc3386e 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_branch.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_branch.go @@ -8,7 +8,7 @@ import ( "fmt" ) -// Branch represents a repository branch. +// Branch represents a repository branch type Branch struct { Name string `json:"name"` Commit *PayloadCommit `json:"commit"` diff --git a/vendor/code.gitea.io/sdk/gitea/repo_collaborator.go b/vendor/code.gitea.io/sdk/gitea/repo_collaborator.go index 546f2476e3..bd61a22cec 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_collaborator.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_collaborator.go @@ -33,7 +33,7 @@ func (c *Client) IsCollaborator(user, repo, collaborator string) (bool, error) { return false, nil } -// AddCollaboratorOption options when add some user as a collaborator of a repository +// AddCollaboratorOption options when adding a user as a collaborator of a repository type AddCollaboratorOption struct { Permission *string `json:"permission"` } diff --git a/vendor/code.gitea.io/sdk/gitea/repo_key.go b/vendor/code.gitea.io/sdk/gitea/repo_key.go index f5f88cd051..03f626cd6e 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_key.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_key.go @@ -17,6 +17,7 @@ type DeployKey struct { Key string `json:"key"` URL string `json:"url"` Title string `json:"title"` + // swagger:strfmt date-time Created time.Time `json:"created_at"` ReadOnly bool `json:"read_only"` } @@ -33,18 +34,15 @@ func (c *Client) GetDeployKey(user, repo string, keyID int64) (*DeployKey, error return key, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys/%d", user, repo, keyID), nil, nil, &key) } -// CreateKeyOption options when create deploy key -// swagger:parameters userCurrentPostKey adminCreatePublicKey +// CreateKeyOption options when creating a key type CreateKeyOption struct { // Title of the key to add // - // in: body // required: true // unique: true Title string `json:"title" binding:"Required"` // An armored SSH key to add // - // in: body // required: true // unique: true Key string `json:"key" binding:"Required"` diff --git a/vendor/code.gitea.io/sdk/gitea/repo_watch.go b/vendor/code.gitea.io/sdk/gitea/repo_watch.go index 02c5d9b0d3..1005f9fbd8 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_watch.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_watch.go @@ -10,8 +10,7 @@ import ( "time" ) -// WatchInfo represents a API watch status of one repository -// swagger:response WatchInfo +// WatchInfo represents an API watch status of one repository type WatchInfo struct { Subscribed bool `json:"subscribed"` Ignored bool `json:"ignored"` diff --git a/vendor/code.gitea.io/sdk/gitea/status.go b/vendor/code.gitea.io/sdk/gitea/status.go index d5cdcd57b7..5ce25321af 100644 --- a/vendor/code.gitea.io/sdk/gitea/status.go +++ b/vendor/code.gitea.io/sdk/gitea/status.go @@ -37,7 +37,9 @@ type Status struct { URL string `json:"url"` Context string `json:"context"` Creator *User `json:"creator"` + // swagger:strfmt date-time Created time.Time `json:"created_at"` + // swagger:strfmt date-time Updated time.Time `json:"updated_at"` } diff --git a/vendor/code.gitea.io/sdk/gitea/user.go b/vendor/code.gitea.io/sdk/gitea/user.go index 9fe2edcbf2..d104cc9933 100644 --- a/vendor/code.gitea.io/sdk/gitea/user.go +++ b/vendor/code.gitea.io/sdk/gitea/user.go @@ -9,20 +9,21 @@ import ( "fmt" ) -// User represents a API user. -// swagger:response User +// User represents a user +// swagger:model type User struct { + // the user's id ID int64 `json:"id"` + // the user's username UserName string `json:"login"` + // the user's full name FullName string `json:"full_name"` + // swagger:strfmt email Email string `json:"email"` + // URL to the user's avatar AvatarURL string `json:"avatar_url"` } -// UserList represents a list of API user. -// swagger:response UserList -type UserList []*User - // MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility func (u User) MarshalJSON() ([]byte, error) { // Re-declaring User to avoid recursion diff --git a/vendor/code.gitea.io/sdk/gitea/user_email.go b/vendor/code.gitea.io/sdk/gitea/user_email.go index e167b5dfbd..721f52144b 100644 --- a/vendor/code.gitea.io/sdk/gitea/user_email.go +++ b/vendor/code.gitea.io/sdk/gitea/user_email.go @@ -9,8 +9,9 @@ import ( "encoding/json" ) -// Email en email information of user +// Email an email address belonging to a user type Email struct { + // swagger:strfmt email Email string `json:"email"` Verified bool `json:"verified"` Primary bool `json:"primary"` @@ -22,8 +23,9 @@ func (c *Client) ListEmails() ([]*Email, error) { return emails, c.getParsedResponse("GET", "/user/emails", nil, nil, &emails) } -// CreateEmailOption options when create an email +// CreateEmailOption options when creating email addresses type CreateEmailOption struct { + // email addresses to add Emails []string `json:"emails"` } @@ -37,8 +39,14 @@ func (c *Client) AddEmail(opt CreateEmailOption) ([]*Email, error) { return emails, c.getParsedResponse("POST", "/user/emails", jsonHeader, bytes.NewReader(body), emails) } +// DeleteEmailOption options when deleting email addresses +type DeleteEmailOption struct { + // email addresses to delete + Emails []string `json:"emails"` +} + // DeleteEmail delete one email of current users' -func (c *Client) DeleteEmail(opt CreateEmailOption) error { +func (c *Client) DeleteEmail(opt DeleteEmailOption) error { body, err := json.Marshal(&opt) if err != nil { return err diff --git a/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go b/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go index 87dd749e6c..ae5dcdcb10 100644 --- a/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go +++ b/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go @@ -11,12 +11,7 @@ import ( "time" ) -// GPGKeyList represents a list of GPGKey -// swagger:response GPGKeyList -type GPGKeyList []*GPGKey - // GPGKey a user GPG key to sign commit and tag in repository -// swagger:response GPGKey type GPGKey struct { ID int64 `json:"id"` PrimaryKeyID string `json:"primary_key_id"` @@ -28,7 +23,9 @@ type GPGKey struct { CanEncryptComms bool `json:"can_encrypt_comms"` CanEncryptStorage bool `json:"can_encrypt_storage"` CanCertify bool `json:"can_certify"` + // swagger:strfmt date-time Created time.Time `json:"created_at,omitempty"` + // swagger:strfmt date-time Expires time.Time `json:"expires_at,omitempty"` } @@ -40,11 +37,9 @@ type GPGKeyEmail struct { } // CreateGPGKeyOption options create user GPG key -// swagger:parameters userCurrentPostGPGKey type CreateGPGKeyOption struct { // An armored GPG key to add // - // in: body // required: true // unique: true ArmoredKey string `json:"armored_public_key" binding:"Required"` diff --git a/vendor/code.gitea.io/sdk/gitea/user_key.go b/vendor/code.gitea.io/sdk/gitea/user_key.go index 397c6d17ac..419c0a56d3 100644 --- a/vendor/code.gitea.io/sdk/gitea/user_key.go +++ b/vendor/code.gitea.io/sdk/gitea/user_key.go @@ -11,17 +11,13 @@ import ( "time" ) -// PublicKeyList represents a list of PublicKey -// swagger:response PublicKeyList -type PublicKeyList []*PublicKey - // PublicKey publickey is a user key to push code to repository -// swagger:response PublicKey type PublicKey struct { ID int64 `json:"id"` Key string `json:"key"` URL string `json:"url,omitempty"` Title string `json:"title,omitempty"` + // swagger:strfmt date-time Created time.Time `json:"created_at,omitempty"` } diff --git a/vendor/vendor.json b/vendor/vendor.json index bd613945af..a26f1f8d40 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -9,10 +9,10 @@ "revisionTime": "2017-10-23T00:52:09Z" }, { - "checksumSHA1": "Zgp5RqU+20L2p9TNl1rSsUIWEEE=", + "checksumSHA1": "OICEgmUefW4L4l/FK/NVFnl/aOM=", "path": "code.gitea.io/sdk/gitea", - "revision": "bc243ad6c268d60658c71185452334b300c268cf", - "revisionTime": "2017-08-21T08:23:17Z" + "revision": "1da52cf95ff3e7953227cfa0469e1c05a7d02557", + "revisionTime": "2017-11-12T09:10:33Z" }, { "checksumSHA1": "bOODD4Gbw3GfcuQPU2dI40crxxk=",