update api docs (#297)

script is now standalone instead of being CI only.
Added a post 1.25 rule for templates since the variables in template changed after https://gitea.com/gitea/gitea-mirror/commit/3533263ced8
Fixes: https://github.com/go-gitea/gitea/issues/35964

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/docs/pulls/297
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: TheFox0x7 <thefox0x7@gmail.com>
Co-committed-by: TheFox0x7 <thefox0x7@gmail.com>
This commit is contained in:
TheFox0x7
2025-11-23 18:43:58 +00:00
committed by Lunny Xiao
parent 826ff60fd4
commit e3cc4ec689
8 changed files with 2083 additions and 99 deletions

View File

@@ -11,20 +11,8 @@ jobs:
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- run: | - run: |
wget https://raw.githubusercontent.com/go-gitea/gitea/refs/heads/main/templates/swagger/v1_json.tmpl make update-api-docs
sed -i "$@" 's\"version": "{{AppVer | JSEscape}}"\"version": "dev"\' v1_json.tmpl
sed -i "$@" 's\"basePath": "{{AppSubUrl | JSEscape}}/api/v1"\"basePath": "https://gitea.com/api/v1"\' v1_json.tmpl
mv v1_json.tmpl static/swagger-latest.json
for ver in '1.25.1' '1.24.7' '1.23.8' '1.22.6'; do
wget https://raw.githubusercontent.com/go-gitea/gitea/refs/tags/v${ver}/templates/swagger/v1_json.tmpl
sed -i "$@" "s|\"version\": \"{{AppVer \| JSEscape}}\"|\"version\": \"${ver}\"|" v1_json.tmpl
sed -i "$@" 's\"basePath": "{{AppSubUrl | JSEscape}}/api/v1"\"basePath": "https://gitea.com/api/v1"\' v1_json.tmpl
minor=$(echo "$ver" | cut -d '.' -f 2)
mv v1_json.tmpl static/swagger-$minor.json
done
if ! [[ $(git diff --shortstat) ]]; then exit 0; fi
git config --global user.name "Gitea Bot" git config --global user.name "Gitea Bot"
git config --global user.email "teabot@gitea.io" git config --global user.email "teabot@gitea.io"
git remote set-url origin https://x-access-token:${{ secrets.DEPLOY_TOKEN }}@gitea.com/gitea/docs.git git remote set-url origin https://x-access-token:${{ secrets.DEPLOY_TOKEN }}@gitea.com/gitea/docs.git

View File

@@ -52,3 +52,7 @@ clean:
rm -rf static/swagger-22.json rm -rf static/swagger-22.json
rm -rf static/swagger-23.json rm -rf static/swagger-23.json
rm -rf static/swagger-24.json rm -rf static/swagger-24.json
.PHONY: update-api-docs
update-api-docs:
./update_api_docs.sh

View File

@@ -19,9 +19,9 @@
"name": "MIT", "name": "MIT",
"url": "http://opensource.org/licenses/MIT" "url": "http://opensource.org/licenses/MIT"
}, },
"version": "{{AppVer | JSEscape}}" "version": "1.22.6"
}, },
"basePath": "{{AppSubUrl | JSEscape}}/api/v1", "basePath": "https://gitea.com/api/v1",
"paths": { "paths": {
"/activitypub/user-id/{user-id}": { "/activitypub/user-id/{user-id}": {
"get": { "get": {
@@ -3444,107 +3444,125 @@
"operationId": "issueSearchIssues", "operationId": "issueSearchIssues",
"parameters": [ "parameters": [
{ {
"enum": [
"open",
"closed",
"all"
],
"type": "string", "type": "string",
"description": "whether issue is open or closed", "default": "open",
"description": "State of the issue",
"name": "state", "name": "state",
"in": "query" "in": "query"
}, },
{ {
"type": "string", "type": "string",
"description": "comma separated list of labels. Fetch only issues that have any of this labels. Non existent labels are discarded", "description": "Comma-separated list of label names. Fetch only issues that have any of these labels. Non existent labels are discarded.",
"name": "labels", "name": "labels",
"in": "query" "in": "query"
}, },
{ {
"type": "string", "type": "string",
"description": "comma separated list of milestone names. Fetch only issues that have any of this milestones. Non existent are discarded", "description": "Comma-separated list of milestone names. Fetch only issues that have any of these milestones. Non existent milestones are discarded.",
"name": "milestones", "name": "milestones",
"in": "query" "in": "query"
}, },
{ {
"type": "string", "type": "string",
"description": "search string", "description": "Search string",
"name": "q", "name": "q",
"in": "query" "in": "query"
}, },
{ {
"type": "integer", "type": "integer",
"format": "int64", "format": "int64",
"description": "repository to prioritize in the results", "description": "Repository ID to prioritize in the results",
"name": "priority_repo_id", "name": "priority_repo_id",
"in": "query" "in": "query"
}, },
{ {
"enum": [
"issues",
"pulls"
],
"type": "string", "type": "string",
"description": "filter by type (issues / pulls) if set", "description": "Filter by issue type",
"name": "type", "name": "type",
"in": "query" "in": "query"
}, },
{ {
"type": "string", "type": "string",
"format": "date-time", "format": "date-time",
"description": "Only show notifications updated after the given time. This is a timestamp in RFC 3339 format", "description": "Only show issues updated after the given time (RFC 3339 format)",
"name": "since", "name": "since",
"in": "query" "in": "query"
}, },
{ {
"type": "string", "type": "string",
"format": "date-time", "format": "date-time",
"description": "Only show notifications updated before the given time. This is a timestamp in RFC 3339 format", "description": "Only show issues updated before the given time (RFC 3339 format)",
"name": "before", "name": "before",
"in": "query" "in": "query"
}, },
{ {
"type": "boolean", "type": "boolean",
"description": "filter (issues / pulls) assigned to you, default is false", "default": false,
"description": "Filter issues or pulls assigned to the authenticated user",
"name": "assigned", "name": "assigned",
"in": "query" "in": "query"
}, },
{ {
"type": "boolean", "type": "boolean",
"description": "filter (issues / pulls) created by you, default is false", "default": false,
"description": "Filter issues or pulls created by the authenticated user",
"name": "created", "name": "created",
"in": "query" "in": "query"
}, },
{ {
"type": "boolean", "type": "boolean",
"description": "filter (issues / pulls) mentioning you, default is false", "default": false,
"description": "Filter issues or pulls mentioning the authenticated user",
"name": "mentioned", "name": "mentioned",
"in": "query" "in": "query"
}, },
{ {
"type": "boolean", "type": "boolean",
"description": "filter pulls requesting your review, default is false", "default": false,
"description": "Filter pull requests where the authenticated user's review was requested",
"name": "review_requested", "name": "review_requested",
"in": "query" "in": "query"
}, },
{ {
"type": "boolean", "type": "boolean",
"description": "filter pulls reviewed by you, default is false", "default": false,
"description": "Filter pull requests reviewed by the authenticated user",
"name": "reviewed", "name": "reviewed",
"in": "query" "in": "query"
}, },
{ {
"type": "string", "type": "string",
"description": "filter by owner", "description": "Filter by repository owner",
"name": "owner", "name": "owner",
"in": "query" "in": "query"
}, },
{ {
"type": "string", "type": "string",
"description": "filter by team (requires organization owner parameter to be provided)", "description": "Filter by team (requires organization owner parameter)",
"name": "team", "name": "team",
"in": "query" "in": "query"
}, },
{ {
"minimum": 1,
"type": "integer", "type": "integer",
"description": "page number of results to return (1-based)", "default": 1,
"description": "Page number of results to return (1-based)",
"name": "page", "name": "page",
"in": "query" "in": "query"
}, },
{ {
"minimum": 0,
"type": "integer", "type": "integer",
"description": "page size of results", "description": "Number of items per page",
"name": "limit", "name": "limit",
"in": "query" "in": "query"
} }
@@ -3552,6 +3570,12 @@
"responses": { "responses": {
"200": { "200": {
"$ref": "#/responses/IssueList" "$ref": "#/responses/IssueList"
},
"400": {
"$ref": "#/responses/error"
},
"422": {
"$ref": "#/responses/validationError"
} }
} }
} }
@@ -3843,6 +3867,39 @@
} }
} }
}, },
"/repos/{owner}/{repo}/actions/runners/registration-token": {
"get": {
"produces": [
"application/json"
],
"tags": [
"repository"
],
"summary": "Get a repository's actions runner registration token",
"operationId": "repoGetRunnerRegistrationToken",
"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/RegistrationToken"
}
}
}
},
"/repos/{owner}/{repo}/actions/secrets": { "/repos/{owner}/{repo}/actions/secrets": {
"get": { "get": {
"produces": [ "produces": [
@@ -5353,7 +5410,7 @@
"tags": [ "tags": [
"repository" "repository"
], ],
"summary": "Get the pull request of the commit", "summary": "Get the merged pull request of the commit",
"operationId": "repoGetCommitPullRequest", "operationId": "repoGetCommitPullRequest",
"parameters": [ "parameters": [
{ {
@@ -7418,6 +7475,9 @@
"404": { "404": {
"$ref": "#/responses/error" "$ref": "#/responses/error"
}, },
"422": {
"$ref": "#/responses/validationError"
},
"423": { "423": {
"$ref": "#/responses/repoArchivedError" "$ref": "#/responses/repoArchivedError"
} }
@@ -8037,6 +8097,9 @@
"404": { "404": {
"$ref": "#/responses/error" "$ref": "#/responses/error"
}, },
"422": {
"$ref": "#/responses/validationError"
},
"423": { "423": {
"$ref": "#/responses/repoArchivedError" "$ref": "#/responses/repoArchivedError"
} }
@@ -12765,6 +12828,9 @@
}, },
"409": { "409": {
"$ref": "#/responses/error" "$ref": "#/responses/error"
},
"422": {
"$ref": "#/responses/validationError"
} }
} }
} }
@@ -12883,8 +12949,8 @@
"404": { "404": {
"$ref": "#/responses/notFound" "$ref": "#/responses/notFound"
}, },
"405": { "422": {
"$ref": "#/responses/empty" "$ref": "#/responses/validationError"
} }
} }
} }
@@ -12969,8 +13035,8 @@
"404": { "404": {
"$ref": "#/responses/notFound" "$ref": "#/responses/notFound"
}, },
"405": { "422": {
"$ref": "#/responses/empty" "$ref": "#/responses/validationError"
} }
} }
}, },
@@ -13330,39 +13396,6 @@
} }
} }
}, },
"/repos/{owner}/{repo}/runners/registration-token": {
"get": {
"produces": [
"application/json"
],
"tags": [
"repository"
],
"summary": "Get a repository's actions runner registration token",
"operationId": "repoGetRunnerRegistrationToken",
"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/RegistrationToken"
}
}
}
},
"/repos/{owner}/{repo}/signing-key.gpg": { "/repos/{owner}/{repo}/signing-key.gpg": {
"get": { "get": {
"produces": [ "produces": [
@@ -13820,6 +13853,9 @@
"409": { "409": {
"$ref": "#/responses/conflict" "$ref": "#/responses/conflict"
}, },
"422": {
"$ref": "#/responses/validationError"
},
"423": { "423": {
"$ref": "#/responses/repoArchivedError" "$ref": "#/responses/repoArchivedError"
} }
@@ -13913,6 +13949,9 @@
"409": { "409": {
"$ref": "#/responses/conflict" "$ref": "#/responses/conflict"
}, },
"422": {
"$ref": "#/responses/validationError"
},
"423": { "423": {
"$ref": "#/responses/repoArchivedError" "$ref": "#/responses/repoArchivedError"
} }
@@ -20595,7 +20634,7 @@
"x-go-name": "Description" "x-go-name": "Description"
}, },
"enable_prune": { "enable_prune": {
"description": "enable prune - remove obsolete remote-tracking references", "description": "enable prune - remove obsolete remote-tracking references when mirroring",
"type": "boolean", "type": "boolean",
"x-go-name": "EnablePrune" "x-go-name": "EnablePrune"
}, },
@@ -21748,12 +21787,9 @@
"type": "object", "type": "object",
"properties": { "properties": {
"labels": { "labels": {
"description": "list of label IDs", "description": "Labels can be a list of integers representing label IDs\nor a list of strings representing label names",
"type": "array", "type": "array",
"items": { "items": {},
"type": "integer",
"format": "int64"
},
"x-go-name": "Labels" "x-go-name": "Labels"
} }
}, },
@@ -21942,7 +21978,7 @@
"type": "object", "type": "object",
"properties": { "properties": {
"Context": { "Context": {
"description": "Context to render\n\nin: body", "description": "URL path for rendering issue, media and file links\nExpected format: /subpath/{user}/{repo}/src/{branch, commit, tag}/{identifier/path}/{file/dir}\n\nin: body",
"type": "string" "type": "string"
}, },
"Mode": { "Mode": {
@@ -21965,7 +22001,7 @@
"type": "object", "type": "object",
"properties": { "properties": {
"Context": { "Context": {
"description": "Context to render\n\nin: body", "description": "URL path for rendering issue, media and file links\nExpected format: /subpath/{user}/{repo}/src/{branch, commit, tag}/{identifier/path}/{file/dir}\n\nin: body",
"type": "string" "type": "string"
}, },
"FilePath": { "FilePath": {
@@ -22820,6 +22856,11 @@
"description": "PullRequest represents a pull request", "description": "PullRequest represents a pull request",
"type": "object", "type": "object",
"properties": { "properties": {
"additions": {
"type": "integer",
"format": "int64",
"x-go-name": "Additions"
},
"allow_maintainer_edit": { "allow_maintainer_edit": {
"type": "boolean", "type": "boolean",
"x-go-name": "AllowMaintainerEdit" "x-go-name": "AllowMaintainerEdit"
@@ -22841,6 +22882,11 @@
"type": "string", "type": "string",
"x-go-name": "Body" "x-go-name": "Body"
}, },
"changed_files": {
"type": "integer",
"format": "int64",
"x-go-name": "ChangedFiles"
},
"closed_at": { "closed_at": {
"type": "string", "type": "string",
"format": "date-time", "format": "date-time",
@@ -22856,10 +22902,19 @@
"format": "date-time", "format": "date-time",
"x-go-name": "Created" "x-go-name": "Created"
}, },
"deletions": {
"type": "integer",
"format": "int64",
"x-go-name": "Deletions"
},
"diff_url": { "diff_url": {
"type": "string", "type": "string",
"x-go-name": "DiffURL" "x-go-name": "DiffURL"
}, },
"draft": {
"type": "boolean",
"x-go-name": "Draft"
},
"due_date": { "due_date": {
"type": "string", "type": "string",
"format": "date-time", "format": "date-time",
@@ -22936,6 +22991,12 @@
}, },
"x-go-name": "RequestedReviewers" "x-go-name": "RequestedReviewers"
}, },
"review_comments": {
"description": "number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR)",
"type": "integer",
"format": "int64",
"x-go-name": "ReviewComments"
},
"state": { "state": {
"$ref": "#/definitions/StateType" "$ref": "#/definitions/StateType"
}, },
@@ -22966,6 +23027,10 @@
"type": "boolean", "type": "boolean",
"x-go-name": "IsWorkInProgress" "x-go-name": "IsWorkInProgress"
}, },
"html_url": {
"type": "string",
"x-go-name": "HTMLURL"
},
"merged": { "merged": {
"type": "boolean", "type": "boolean",
"x-go-name": "HasMerged" "x-go-name": "HasMerged"
@@ -24259,6 +24324,11 @@
"type": "string", "type": "string",
"x-go-name": "FullName" "x-go-name": "FullName"
}, },
"html_url": {
"description": "URL to the user's gitea page",
"type": "string",
"x-go-name": "HTMLURL"
},
"id": { "id": {
"description": "the user's id", "description": "the user's id",
"type": "integer", "type": "integer",

View File

@@ -19,9 +19,9 @@
"name": "MIT", "name": "MIT",
"url": "http://opensource.org/licenses/MIT" "url": "http://opensource.org/licenses/MIT"
}, },
"version": "{{AppVer | JSEscape}}" "version": "1.23.8"
}, },
"basePath": "{{AppSubUrl | JSEscape}}/api/v1", "basePath": "https://gitea.com/api/v1",
"paths": { "paths": {
"/activitypub/user-id/{user-id}": { "/activitypub/user-id/{user-id}": {
"get": { "get": {
@@ -19616,7 +19616,18 @@
"items": { "items": {
"type": "string" "type": "string"
}, },
"x-go-name": "Scopes" "x-go-name": "Scopes",
"example": [
"all",
"read:activitypub",
"read:issue",
"write:misc",
"read:notification",
"read:organization",
"read:package",
"read:repository",
"read:user"
]
} }
}, },
"x-go-package": "code.gitea.io/gitea/modules/structs" "x-go-package": "code.gitea.io/gitea/modules/structs"

File diff suppressed because it is too large Load Diff

View File

@@ -19,9 +19,9 @@
"name": "MIT", "name": "MIT",
"url": "http://opensource.org/licenses/MIT" "url": "http://opensource.org/licenses/MIT"
}, },
"version": "{{.SwaggerAppVer}}" "version": "1.25.1"
}, },
"basePath": "{{.SwaggerAppSubUrl}}/api/v1", "basePath": "https://gitea.com/api/v1",
"paths": { "paths": {
"/activitypub/user-id/{user-id}": { "/activitypub/user-id/{user-id}": {
"get": { "get": {

View File

@@ -19,9 +19,9 @@
"name": "MIT", "name": "MIT",
"url": "http://opensource.org/licenses/MIT" "url": "http://opensource.org/licenses/MIT"
}, },
"version": "{{.SwaggerAppVer}}" "version": "dev"
}, },
"basePath": "{{.SwaggerAppSubUrl}}/api/v1", "basePath": "https://gitea.com/api/v1",
"paths": { "paths": {
"/activitypub/user-id/{user-id}": { "/activitypub/user-id/{user-id}": {
"get": { "get": {

17
update_api_docs.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
curl --silent --output v1_json.tmpl https://raw.githubusercontent.com/go-gitea/gitea/refs/heads/main/templates/swagger/v1_json.tmpl
sed -i "$@" 's|"version": "{{.SwaggerAppVer}}"|"version": "dev"|' v1_json.tmpl
sed -i "$@" 's|"basePath": "{{.SwaggerAppSubUrl}}/api/v1"|"basePath": "https://gitea.com/api/v1"|' v1_json.tmpl
mv v1_json.tmpl static/swagger-latest.json
for ver in '1.25.1' '1.24.7' '1.23.8' '1.22.6'; do
curl --silent --output v1_json.tmpl https://raw.githubusercontent.com/go-gitea/gitea/refs/tags/v${ver}/templates/swagger/v1_json.tmpl
sed -i "$@" "s|\"version\": \"{{.SwaggerAppVer}}\"|\"version\": \"${ver}\"|" v1_json.tmpl
sed -i "$@" 's|"basePath": "{{.SwaggerAppSubUrl}}/api/v1"|"basePath": "https://gitea.com/api/v1"|' v1_json.tmpl
# for versions < 1.24
sed -i "$@" "s|\"version\": \"{{AppVer \| JSEscape}}\"|\"version\": \"${ver}\"|" v1_json.tmpl
sed -i "$@" 's\"basePath": "{{AppSubUrl | JSEscape}}/api/v1"\"basePath": "https://gitea.com/api/v1"\' v1_json.tmpl
minor=$(echo "$ver" | cut -d '.' -f 2)
mv v1_json.tmpl static/swagger-$minor.json
done