mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-26 10:20:29 +00:00
Correct api docs of PostRepo & GetRepos (#1974)
... and report if needed forge_remote_id is not valid
This commit is contained in:
parent
e85eeb10fc
commit
edb92025df
3 changed files with 51 additions and 37 deletions
|
@ -1192,6 +1192,42 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/repos": {
|
||||
"post": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Repositories"
|
||||
],
|
||||
"summary": "Activate a repository",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"default": "Bearer \u003cpersonal access token\u003e",
|
||||
"description": "Insert your personal access token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "the id of a repository at the forge",
|
||||
"name": "forge_remote_id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Repo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/lookup/{repo_full_name}": {
|
||||
"get": {
|
||||
"produces": [
|
||||
|
@ -1263,40 +1299,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Repositories"
|
||||
],
|
||||
"summary": "Activate a repository",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"default": "Bearer \u003cpersonal access token\u003e",
|
||||
"description": "Insert your personal access token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "the repository id",
|
||||
"name": "repo_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Repo"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
|
@ -3116,6 +3118,12 @@ const docTemplate = `{
|
|||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "query not activated repos from forge too",
|
||||
"name": "all",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
|
|
|
@ -39,18 +39,23 @@ import (
|
|||
// PostRepo
|
||||
//
|
||||
// @Summary Activate a repository
|
||||
// @Router /repos/{repo_id} [post]
|
||||
// @Router /repos [post]
|
||||
// @Produce json
|
||||
// @Success 200 {object} Repo
|
||||
// @Tags Repositories
|
||||
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
|
||||
// @Param repo_id path int true "the repository id"
|
||||
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
|
||||
// @Param forge_remote_id query string true "the id of a repository at the forge"
|
||||
func PostRepo(c *gin.Context) {
|
||||
forge := server.Config.Services.Forge
|
||||
_store := store.FromContext(c)
|
||||
user := session.User(c)
|
||||
|
||||
forgeRemoteID := model.ForgeRemoteID(c.Query("forge_remote_id"))
|
||||
if !forgeRemoteID.IsValid() {
|
||||
c.String(http.StatusBadRequest, "No forge_remote_id provided")
|
||||
return
|
||||
}
|
||||
|
||||
repo, err := _store.GetRepoForgeID(forgeRemoteID)
|
||||
enabledOnce := err == nil // if there's no error, the repo was found and enabled once already
|
||||
if enabledOnce && repo.IsActive {
|
||||
|
|
|
@ -82,6 +82,7 @@ func GetFeed(c *gin.Context) {
|
|||
// @Success 200 {array} Repo
|
||||
// @Tags User
|
||||
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
|
||||
// @Param all query bool false "query not activated repos from forge too"
|
||||
func GetRepos(c *gin.Context) {
|
||||
_store := store.FromContext(c)
|
||||
_forge := server.Config.Services.Forge
|
||||
|
|
Loading…
Reference in a new issue