summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorDavid Svantesson <davidsvantesson@gmail.com>2019-09-03 17:46:24 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2019-09-03 23:46:24 +0800
commit1f951cdebae314a45b5e4ec1d464f1b4a53c8002 (patch)
tree5c22a1872beaa218599374678491a2fd66323075 /templates
parent99d6863238d8717c2f14bc72ab023a0f683c50cc (diff)
downloadgitea-1f951cdebae314a45b5e4ec1d464f1b4a53c8002.tar.gz
gitea-1f951cdebae314a45b5e4ec1d464f1b4a53c8002.zip
Add API endpoint for accessing repo topics (#7963)
* Create API endpoints for repo topics. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Generate swagger Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Add documentation to functions Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Grammar fix Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Fix function comment Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Can't use FindTopics when looking for a single repo topic, as it doesnt use exact match Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Add PUT ​/repos​/{owner}​/{repo}​/topics and remove GET ​/repos​/{owner}​/{repo}​/topics * Ignore if topic is sent twice in same request, refactoring. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Fix topic dropdown with api changes. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Style fix Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Update API documentation Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Better way to handle duplicate topics in slice Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Make response element TopicName an array of strings, instead of using an array of TopicName Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Add test cases for API Repo Topics. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Fix format of tests Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Fix comments Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Fix unit tests after adding some more topics to the test fixture. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Update models/topic.go Limit multiple if else if ... Co-Authored-By: Antoine GIRARD <sapk@users.noreply.github.com> * Engine as first parameter in function Co-Authored-By: Antoine GIRARD <sapk@users.noreply.github.com> * Replace magic numbers with http status code constants. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Fix variable scope Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Test one read with login and one with token Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Add some more tests Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Apply suggestions from code review Use empty struct for efficiency Co-Authored-By: Lauris BH <lauris@nix.lv> * Add test case to check access for user with write access Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Fix access, repo admin required to change topics Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Correct first test to be without token Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Any repo reader should be able to access topics. * No need for string pointer Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
Diffstat (limited to 'templates')
-rw-r--r--templates/swagger/v1_json.tmpl228
1 files changed, 226 insertions, 2 deletions
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl
index eed60c044c..8cf22251a6 100644
--- a/templates/swagger/v1_json.tmpl
+++ b/templates/swagger/v1_json.tmpl
@@ -5451,6 +5451,155 @@
}
}
},
+ "/repos/{owner}/{repo}/topics": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "repository"
+ ],
+ "summary": "Get list of topics that a repository has",
+ "operationId": "repoListTopics",
+ "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/TopicNames"
+ }
+ }
+ },
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "repository"
+ ],
+ "summary": "Replace list of topics for a repository",
+ "operationId": "repoUpdateTopics",
+ "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/RepoTopicOptions"
+ }
+ }
+ ],
+ "responses": {
+ "204": {
+ "$ref": "#/responses/empty"
+ }
+ }
+ }
+ },
+ "/repos/{owner}/{repo}/topics/{topic}": {
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "repository"
+ ],
+ "summary": "Add a topic to a repository",
+ "operationId": "repoAddTopíc",
+ "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 the topic to add",
+ "name": "topic",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "$ref": "#/responses/empty"
+ }
+ }
+ },
+ "delete": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "repository"
+ ],
+ "summary": "Delete a topic from a repository",
+ "operationId": "repoDeleteTopic",
+ "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 the topic to delete",
+ "name": "topic",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "204": {
+ "$ref": "#/responses/empty"
+ }
+ }
+ }
+ },
"/repositories/{id}": {
"get": {
"produces": [
@@ -5815,7 +5964,7 @@
],
"responses": {
"200": {
- "$ref": "#/responses/Repository"
+ "$ref": "#/responses/TopicListResponse"
}
}
}
@@ -9561,6 +9710,21 @@
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
+ "RepoTopicOptions": {
+ "description": "RepoTopicOptions a collection of repo topic names",
+ "type": "object",
+ "properties": {
+ "topics": {
+ "description": "list of topic names",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "Topics"
+ }
+ },
+ "x-go-package": "code.gitea.io/gitea/modules/structs"
+ },
"Repository": {
"description": "Repository represents a repository",
"type": "object",
@@ -9874,6 +10038,51 @@
"format": "int64",
"x-go-package": "code.gitea.io/gitea/modules/timeutil"
},
+ "TopicName": {
+ "description": "TopicName a list of repo topic names",
+ "type": "object",
+ "properties": {
+ "topics": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "x-go-name": "TopicNames"
+ }
+ },
+ "x-go-package": "code.gitea.io/gitea/modules/structs"
+ },
+ "TopicResponse": {
+ "description": "TopicResponse for returning topics",
+ "type": "object",
+ "properties": {
+ "created": {
+ "type": "string",
+ "format": "date-time",
+ "x-go-name": "Created"
+ },
+ "id": {
+ "type": "integer",
+ "format": "int64",
+ "x-go-name": "ID"
+ },
+ "repo_count": {
+ "type": "integer",
+ "format": "int64",
+ "x-go-name": "RepoCount"
+ },
+ "topic_name": {
+ "type": "string",
+ "x-go-name": "Name"
+ },
+ "updated": {
+ "type": "string",
+ "format": "date-time",
+ "x-go-name": "Updated"
+ }
+ },
+ "x-go-package": "code.gitea.io/gitea/modules/structs"
+ },
"TrackedTime": {
"description": "TrackedTime worked time for an issue / pr",
"type": "object",
@@ -10493,6 +10702,21 @@
}
}
},
+ "TopicListResponse": {
+ "description": "TopicListResponse",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/TopicResponse"
+ }
+ }
+ },
+ "TopicNames": {
+ "description": "TopicNames",
+ "schema": {
+ "$ref": "#/definitions/TopicName"
+ }
+ },
"TrackedTime": {
"description": "TrackedTime",
"schema": {
@@ -10569,7 +10793,7 @@
"parameterBodies": {
"description": "parameterBodies",
"schema": {
- "$ref": "#/definitions/DeleteFileOptions"
+ "$ref": "#/definitions/RepoTopicOptions"
}
},
"redirect": {