mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
fix: added swagger doc generation for mgmt and userprefs (#1530)
Signed-off-by: Lisca Ana-Roberta <ana.kagome@yahoo.com>
This commit is contained in:
parent
fc6d6356fb
commit
aa16c955b3
5 changed files with 414 additions and 3 deletions
|
@ -70,6 +70,14 @@ type mgmt struct {
|
|||
log log.Logger
|
||||
}
|
||||
|
||||
// mgmtHandler godoc
|
||||
// @Summary Get current server configuration
|
||||
// @Description Get current server configuration
|
||||
// @Router /v2/_zot/ext/mgmt [get]
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} extensions.StrippedConfig
|
||||
// @Failure 500 {string} string "internal server error".
|
||||
func (mgmt *mgmt) handler() http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
sanitizedConfig := mgmt.config.Sanitize()
|
||||
|
|
|
@ -43,6 +43,19 @@ func SetupUserPreferencesRoutes(config *config.Config, router *mux.Router, store
|
|||
}
|
||||
}
|
||||
|
||||
// ListTags godoc
|
||||
// @Summary Add bookmarks/stars info
|
||||
// @Description Add bookmarks/stars info
|
||||
// @Router /v2/_zot/ext/userprefs [put]
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param action query string true "specify action" Enums("toggleBookmark", "toggleStar")
|
||||
// @Param repo query string true "repository name"
|
||||
// @Success 200 {string} string "ok"
|
||||
// @Failure 404 {string} string "not found"
|
||||
// @Failure 403 {string} string "forbidden"
|
||||
// @Failure 500 {string} string "internal server error"
|
||||
// @Failure 400 {string} string "bad request".
|
||||
func HandleUserPrefs(repoDB repodb.RepoDB, log log.Logger) func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(rsp http.ResponseWriter, req *http.Request) {
|
||||
if !queryHasParams(req.URL.Query(), []string{"action"}) {
|
||||
|
|
149
swagger/docs.go
149
swagger/docs.go
|
@ -141,6 +141,96 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/v2/_zot/ext/mgmt": {
|
||||
"get": {
|
||||
"description": "Get current server configuration",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"summary": "Get current server configuration",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/extensions.StrippedConfig"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error\".",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v2/_zot/ext/userprefs": {
|
||||
"put": {
|
||||
"description": "Add bookmarks/stars info",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"summary": "Add bookmarks/stars info",
|
||||
"parameters": [
|
||||
{
|
||||
"enum": [
|
||||
"\"toggleBookmark\"",
|
||||
"\"toggleStar\""
|
||||
],
|
||||
"type": "string",
|
||||
"description": "specify action",
|
||||
"name": "action",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "repository name",
|
||||
"name": "repo",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "bad request\".",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "forbidden",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "not found",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v2/{name}/blobs/uploads": {
|
||||
"post": {
|
||||
"description": "Create a new image blob/layer upload",
|
||||
|
@ -927,6 +1017,36 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"extensions.Auth": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"bearer": {
|
||||
"$ref": "#/definitions/extensions.BearerConfig"
|
||||
},
|
||||
"htpasswd": {
|
||||
"$ref": "#/definitions/extensions.HTPasswd"
|
||||
},
|
||||
"ldap": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"address": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"extensions.BearerConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"realm": {
|
||||
"type": "string"
|
||||
},
|
||||
"service": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extensions.Extension": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -947,6 +1067,33 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"extensions.HTPasswd": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extensions.StrippedConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"binaryType": {
|
||||
"type": "string"
|
||||
},
|
||||
"distSpecVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"http": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"auth": {
|
||||
"$ref": "#/definitions/extensions.Auth"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"github_com_opencontainers_image-spec_specs-go_v1.Descriptor": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -1001,7 +1148,7 @@ const docTemplate = `{
|
|||
"type": "object",
|
||||
"properties": {
|
||||
"architecture": {
|
||||
"description": "Architecture field specifies the CPU architecture, for example\n` + "`" + `amd64` + "`" + ` or ` + "`" + `ppc64` + "`" + `.",
|
||||
"description": "Architecture field specifies the CPU architecture, for example\n` + "`" + `amd64` + "`" + ` or ` + "`" + `ppc64le` + "`" + `.",
|
||||
"type": "string"
|
||||
},
|
||||
"os": {
|
||||
|
|
|
@ -132,6 +132,96 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/v2/_zot/ext/mgmt": {
|
||||
"get": {
|
||||
"description": "Get current server configuration",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"summary": "Get current server configuration",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/extensions.StrippedConfig"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error\".",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v2/_zot/ext/userprefs": {
|
||||
"put": {
|
||||
"description": "Add bookmarks/stars info",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"summary": "Add bookmarks/stars info",
|
||||
"parameters": [
|
||||
{
|
||||
"enum": [
|
||||
"\"toggleBookmark\"",
|
||||
"\"toggleStar\""
|
||||
],
|
||||
"type": "string",
|
||||
"description": "specify action",
|
||||
"name": "action",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "repository name",
|
||||
"name": "repo",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "bad request\".",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "forbidden",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "not found",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v2/{name}/blobs/uploads": {
|
||||
"post": {
|
||||
"description": "Create a new image blob/layer upload",
|
||||
|
@ -918,6 +1008,36 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"extensions.Auth": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"bearer": {
|
||||
"$ref": "#/definitions/extensions.BearerConfig"
|
||||
},
|
||||
"htpasswd": {
|
||||
"$ref": "#/definitions/extensions.HTPasswd"
|
||||
},
|
||||
"ldap": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"address": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"extensions.BearerConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"realm": {
|
||||
"type": "string"
|
||||
},
|
||||
"service": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extensions.Extension": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -938,6 +1058,33 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"extensions.HTPasswd": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extensions.StrippedConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"binaryType": {
|
||||
"type": "string"
|
||||
},
|
||||
"distSpecVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"http": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"auth": {
|
||||
"$ref": "#/definitions/extensions.Auth"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"github_com_opencontainers_image-spec_specs-go_v1.Descriptor": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -992,7 +1139,7 @@
|
|||
"type": "object",
|
||||
"properties": {
|
||||
"architecture": {
|
||||
"description": "Architecture field specifies the CPU architecture, for example\n`amd64` or `ppc64`.",
|
||||
"description": "Architecture field specifies the CPU architecture, for example\n`amd64` or `ppc64le`.",
|
||||
"type": "string"
|
||||
},
|
||||
"os": {
|
||||
|
|
|
@ -78,6 +78,25 @@ definitions:
|
|||
type: string
|
||||
type: array
|
||||
type: object
|
||||
extensions.Auth:
|
||||
properties:
|
||||
bearer:
|
||||
$ref: '#/definitions/extensions.BearerConfig'
|
||||
htpasswd:
|
||||
$ref: '#/definitions/extensions.HTPasswd'
|
||||
ldap:
|
||||
properties:
|
||||
address:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
extensions.BearerConfig:
|
||||
properties:
|
||||
realm:
|
||||
type: string
|
||||
service:
|
||||
type: string
|
||||
type: object
|
||||
extensions.Extension:
|
||||
properties:
|
||||
description:
|
||||
|
@ -91,6 +110,23 @@ definitions:
|
|||
url:
|
||||
type: string
|
||||
type: object
|
||||
extensions.HTPasswd:
|
||||
properties:
|
||||
path:
|
||||
type: string
|
||||
type: object
|
||||
extensions.StrippedConfig:
|
||||
properties:
|
||||
binaryType:
|
||||
type: string
|
||||
distSpecVersion:
|
||||
type: string
|
||||
http:
|
||||
properties:
|
||||
auth:
|
||||
$ref: '#/definitions/extensions.Auth'
|
||||
type: object
|
||||
type: object
|
||||
github_com_opencontainers_image-spec_specs-go_v1.Descriptor:
|
||||
properties:
|
||||
annotations:
|
||||
|
@ -138,7 +174,7 @@ definitions:
|
|||
architecture:
|
||||
description: |-
|
||||
Architecture field specifies the CPU architecture, for example
|
||||
`amd64` or `ppc64`.
|
||||
`amd64` or `ppc64le`.
|
||||
type: string
|
||||
os:
|
||||
description: OS specifies the operating system, for example `linux` or `windows`.
|
||||
|
@ -250,6 +286,66 @@ paths:
|
|||
schema:
|
||||
$ref: '#/definitions/api.ExtensionList'
|
||||
summary: List Registry level extensions
|
||||
/v2/_zot/ext/mgmt:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Get current server configuration
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/extensions.StrippedConfig'
|
||||
"500":
|
||||
description: internal server error".
|
||||
schema:
|
||||
type: string
|
||||
summary: Get current server configuration
|
||||
/v2/_zot/ext/userprefs:
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Add bookmarks/stars info
|
||||
parameters:
|
||||
- description: specify action
|
||||
enum:
|
||||
- '"toggleBookmark"'
|
||||
- '"toggleStar"'
|
||||
in: query
|
||||
name: action
|
||||
required: true
|
||||
type: string
|
||||
- description: repository name
|
||||
in: query
|
||||
name: repo
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
schema:
|
||||
type: string
|
||||
"400":
|
||||
description: bad request".
|
||||
schema:
|
||||
type: string
|
||||
"403":
|
||||
description: forbidden
|
||||
schema:
|
||||
type: string
|
||||
"404":
|
||||
description: not found
|
||||
schema:
|
||||
type: string
|
||||
"500":
|
||||
description: internal server error
|
||||
schema:
|
||||
type: string
|
||||
summary: Add bookmarks/stars info
|
||||
/v2/{name}/blobs/{digest}:
|
||||
delete:
|
||||
consumes:
|
||||
|
|
Loading…
Reference in a new issue