diff options
author | Denys Konovalov <privat@denyskon.de> | 2023-05-29 11:41:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-29 17:41:35 +0800 |
commit | 275d4b7e3f4595206e5c4b1657d4f6d6969d9ce2 (patch) | |
tree | 4283f97bce56c7783e6c77c380cbe4ce06277720 /templates/swagger | |
parent | 245f2c08db34e535576633748fc143bb09097ca8 (diff) | |
download | gitea-275d4b7e3f4595206e5c4b1657d4f6d6969d9ce2.tar.gz gitea-275d4b7e3f4595206e5c4b1657d4f6d6969d9ce2.zip |
API endpoint for changing/creating/deleting multiple files (#24887)
This PR creates an API endpoint for creating/updating/deleting multiple
files in one API call similar to the solution provided by
[GitLab](https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions).
To archive this, the CreateOrUpdateRepoFile and DeleteRepoFIle functions
in files service are unified into one function supporting multiple files
and actions.
Resolves #14619
Diffstat (limited to 'templates/swagger')
-rw-r--r-- | templates/swagger/v1_json.tmpl | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 15043e465f..75492ab631 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -4063,6 +4063,57 @@ "$ref": "#/responses/notFound" } } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create or update multiple files in a repository", + "operationId": "repoChangeFiles", + "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", + "required": true, + "schema": { + "$ref": "#/definitions/ChangeFilesOptions" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/FilesResponse" + }, + "403": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/error" + } + } } }, "/repos/{owner}/{repo}/contents/{filepath}": { @@ -15891,6 +15942,90 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "ChangeFileOperation": { + "description": "ChangeFileOperation for creating, updating or deleting a file", + "type": "object", + "required": [ + "operation", + "content" + ], + "properties": { + "content": { + "description": "content must be base64 encoded", + "type": "string", + "x-go-name": "Content" + }, + "from_path": { + "description": "old path of the file to move", + "type": "string", + "x-go-name": "FromPath" + }, + "operation": { + "description": "indicates what to do with the file", + "type": "string", + "enum": [ + "create", + "update", + "delete" + ], + "x-go-name": "Operation" + }, + "path": { + "description": "path to the existing or new file", + "type": "string", + "x-go-name": "Path" + }, + "sha": { + "description": "sha is the SHA for the file that already exists, required for update, delete", + "type": "string", + "x-go-name": "SHA" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "ChangeFilesOptions": { + "description": "ChangeFilesOptions options for creating, updating or deleting multiple files\nNote: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", + "type": "object", + "properties": { + "author": { + "$ref": "#/definitions/Identity" + }, + "branch": { + "description": "branch (optional) to base this file from. if not given, the default branch is used", + "type": "string", + "x-go-name": "BranchName" + }, + "committer": { + "$ref": "#/definitions/Identity" + }, + "dates": { + "$ref": "#/definitions/CommitDateOptions" + }, + "files": { + "type": "array", + "items": { + "$ref": "#/definitions/ChangeFileOperation" + }, + "x-go-name": "Files" + }, + "message": { + "description": "message (optional) for the commit of this file. if not supplied, a default message will be used", + "type": "string", + "x-go-name": "Message" + }, + "new_branch": { + "description": "new_branch (optional) will make a new branch from `branch` before creating the file", + "type": "string", + "x-go-name": "NewBranchName" + }, + "signoff": { + "description": "Add a Signed-off-by trailer by the committer at the end of the commit log message.", + "type": "boolean", + "x-go-name": "Signoff" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "ChangedFile": { "description": "ChangedFile store information about files affected by the pull request", "type": "object", @@ -18326,6 +18461,26 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "FilesResponse": { + "description": "FilesResponse contains information about multiple files from a repo", + "type": "object", + "properties": { + "commit": { + "$ref": "#/definitions/FileCommitResponse" + }, + "files": { + "type": "array", + "items": { + "$ref": "#/definitions/ContentsResponse" + }, + "x-go-name": "Files" + }, + "verification": { + "$ref": "#/definitions/PayloadCommitVerification" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "GPGKey": { "description": "GPGKey a user GPG key to sign commit and tag in repository", "type": "object", @@ -21996,6 +22151,12 @@ "$ref": "#/definitions/FileResponse" } }, + "FilesResponse": { + "description": "FilesResponse", + "schema": { + "$ref": "#/definitions/FilesResponse" + } + }, "GPGKey": { "description": "GPGKey", "schema": { |