Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added swagger doc generation for mgmt and userprefs #1530

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/extensions/extension_mgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
13 changes: 13 additions & 0 deletions pkg/extensions/extension_userprefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}) {
Expand Down
149 changes: 148 additions & 1 deletion swagger/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

149 changes: 148 additions & 1 deletion swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand All @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
Loading