mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-20 08:51:01 +00:00
fix and lint swagger file (#3007)
Co-authored-by: qwerty287 <ndev@web.de>
This commit is contained in:
parent
7d43c29c20
commit
3f1f563180
18 changed files with 149 additions and 157 deletions
1
Makefile
1
Makefile
|
@ -105,6 +105,7 @@ generate: generate-swagger ## Run all code generations
|
|||
|
||||
generate-swagger: install-tools ## Run swagger code generation
|
||||
swag init -g server/api/ -g cmd/server/swagger.go --outputTypes go -output cmd/server/docs
|
||||
go generate cmd/server/swagger.go
|
||||
|
||||
generate-license-header: install-tools
|
||||
addlicense -c "Woodpecker Authors" -ignore "vendor/**" **/*.go
|
||||
|
|
|
@ -261,16 +261,9 @@ const docTemplate = `{
|
|||
"summary": "Provide pipeline status information to the CCMenu tool",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "the repository owner's name",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "the repository name",
|
||||
"name": "name",
|
||||
"type": "integer",
|
||||
"description": "the repository id",
|
||||
"name": "repo_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
|
@ -989,6 +982,49 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Organization secrets"
|
||||
],
|
||||
"summary": "Persist/create an organization secret",
|
||||
"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 org's id",
|
||||
"name": "org_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "the new secret",
|
||||
"name": "secretData",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Secret"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Secret"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/orgs/{org_id}/secrets/{secret}": {
|
||||
|
@ -1122,51 +1158,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/orgs/{owner}/secrets": {
|
||||
"post": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Organization secrets"
|
||||
],
|
||||
"summary": "Persist/create an organization secret",
|
||||
"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 org's id",
|
||||
"name": "org_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "the new secret",
|
||||
"name": "secretData",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Secret"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Secret"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/pipelines": {
|
||||
"get": {
|
||||
"produces": [
|
||||
|
@ -2081,16 +2072,9 @@ const docTemplate = `{
|
|||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "the repository owner's name",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "the repository name",
|
||||
"name": "name",
|
||||
"type": "integer",
|
||||
"description": "the repository id",
|
||||
"name": "repo_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
|
@ -2262,16 +2246,9 @@ const docTemplate = `{
|
|||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "the repository owner's name",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "the repository name",
|
||||
"name": "name",
|
||||
"type": "integer",
|
||||
"description": "the repository id",
|
||||
"name": "repo_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
|
||||
// generate docs/swagger.json via:
|
||||
//go:generate go run woodpecker_docs_gen.go swagger.go
|
||||
//go:generate go run github.com/go-swagger/go-swagger/cmd/swagger@latest validate ../../docs/swagger.json
|
||||
|
||||
// setupSwaggerStaticConfig initializes static content only (contacts, title and description)
|
||||
// for dynamic configuration of e.g. hostname, etc. see router.setupSwaggerConfigAndRoutes
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
|
@ -38,8 +39,23 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
_, err = f.WriteString(docs.SwaggerInfo.ReadDoc())
|
||||
doc := docs.SwaggerInfo.ReadDoc()
|
||||
doc = removeHost(doc)
|
||||
_, err = f.WriteString(doc)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func removeHost(jsonIn string) string {
|
||||
m := make(map[string]interface{})
|
||||
if err := json.Unmarshal([]byte(jsonIn), &m); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
delete(m, "host")
|
||||
raw, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return string(raw)
|
||||
}
|
||||
|
|
|
@ -97,8 +97,7 @@ func GetBadge(c *gin.Context) {
|
|||
// @Produce xml
|
||||
// @Success 200
|
||||
// @Tags Badges
|
||||
// @Param owner path string true "the repository owner's name"
|
||||
// @Param name path string true "the repository name"
|
||||
// @Param repo_id path int true "the repository id"
|
||||
func GetCC(c *gin.Context) {
|
||||
_store := store.FromContext(c)
|
||||
var repo *model.Repo
|
||||
|
|
|
@ -87,7 +87,7 @@ func GetOrgSecretList(c *gin.Context) {
|
|||
// PostOrgSecret
|
||||
//
|
||||
// @Summary Persist/create an organization secret
|
||||
// @Router /orgs/{owner}/secrets [post]
|
||||
// @Router /orgs/{org_id}/secrets [post]
|
||||
// @Produce json
|
||||
// @Success 200 {object} Secret
|
||||
// @Tags Organization secrets
|
||||
|
|
|
@ -378,8 +378,7 @@ func GetPipelineQueue(c *gin.Context) {
|
|||
// @Success 200 {object} Pipeline
|
||||
// @Tags Pipelines
|
||||
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
|
||||
// @Param owner path string true "the repository owner's name"
|
||||
// @Param name path string true "the repository name"
|
||||
// @Param repo_id path int true "the repository id"
|
||||
// @Param number path int true "the number of the pipeline"
|
||||
// @Param event query string false "override the event type"
|
||||
// @Param deploy_to query string false "override the target deploy value"
|
||||
|
|
|
@ -318,8 +318,7 @@ func GetRepo(c *gin.Context) {
|
|||
// @Success 200 {object} Perm
|
||||
// @Tags Repositories
|
||||
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
|
||||
// @Param owner path string true "the repository owner's name"
|
||||
// @Param name path string true "the repository name"
|
||||
// @Param repo_id path int true "the repository id"
|
||||
func GetRepoPermissions(c *gin.Context) {
|
||||
perm := session.Perm(c)
|
||||
c.JSON(http.StatusOK, perm)
|
||||
|
|
Loading…
Reference in a new issue