fix(api): renew endpoint uses get instead of post, correct @Accept docs

This commit is contained in:
yusing
2025-08-17 14:52:56 +08:00
parent e52c86e0b7
commit d1eb3470b5
8 changed files with 23 additions and 64 deletions

View File

@@ -87,7 +87,7 @@ func NewHandler() *gin.Engine {
cert := v1.Group("/cert") cert := v1.Group("/cert")
{ {
cert.GET("/info", certApi.Info) cert.GET("/info", certApi.Info)
cert.POST("/renew", certApi.Renew) cert.GET("/renew", certApi.Renew)
} }
agent := v1.Group("/agent") agent := v1.Group("/agent")

View File

@@ -22,7 +22,6 @@ type CertInfo struct {
// @Summary Get cert info // @Summary Get cert info
// @Description Get cert info // @Description Get cert info
// @Tags cert // @Tags cert
// @Accept json
// @Produce json // @Produce json
// @Success 200 {object} CertInfo // @Success 200 {object} CertInfo
// @Failure 403 {object} apitypes.ErrorResponse // @Failure 403 {object} apitypes.ErrorResponse

View File

@@ -17,13 +17,12 @@ import (
// @BasePath /api/v1 // @BasePath /api/v1
// @Summary Renew cert // @Summary Renew cert
// @Description Renew cert // @Description Renew cert
// @Tags cert // @Tags cert,websocket
// @Accept json // @Produce plain
// @Produce json
// @Success 200 {object} apitypes.SuccessResponse // @Success 200 {object} apitypes.SuccessResponse
// @Failure 403 {object} apitypes.ErrorResponse // @Failure 403 {object} apitypes.ErrorResponse
// @Failure 500 {object} apitypes.ErrorResponse // @Failure 500 {object} apitypes.ErrorResponse
// @Router /cert/renew [post] // @Router /cert/renew [get]
func Renew(c *gin.Context) { func Renew(c *gin.Context) {
autocert := config.GetInstance().AutoCertProvider() autocert := config.GetInstance().AutoCertProvider()
if autocert == nil { if autocert == nil {

View File

@@ -24,7 +24,6 @@ type Container struct {
// @Summary Get containers // @Summary Get containers
// @Description Get containers // @Description Get containers
// @Tags docker // @Tags docker
// @Accept json
// @Produce json // @Produce json
// @Success 200 {array} Container // @Success 200 {array} Container
// @Failure 403 {object} apitypes.ErrorResponse // @Failure 403 {object} apitypes.ErrorResponse

View File

@@ -47,9 +47,8 @@ func toDockerInfo(info dockerSystem.Info) dockerInfo {
// @Summary Get docker info // @Summary Get docker info
// @Description Get docker info // @Description Get docker info
// @Tags docker // @Tags docker
// @Accept json
// @Produce json // @Produce json
// @Success 200 {array} dockerInfo // @Success 200 {object} dockerInfo
// @Failure 403 {object} apitypes.ErrorResponse // @Failure 403 {object} apitypes.ErrorResponse
// @Failure 500 {object} apitypes.ErrorResponse // @Failure 500 {object} apitypes.ErrorResponse
// @Router /docker/info [get] // @Router /docker/info [get]

View File

@@ -301,9 +301,6 @@ const docTemplate = `{
"/cert/info": { "/cert/info": {
"get": { "get": {
"description": "Get cert info", "description": "Get cert info",
"consumes": [
"application/json"
],
"produces": [ "produces": [
"application/json" "application/json"
], ],
@@ -341,16 +338,14 @@ const docTemplate = `{
} }
}, },
"/cert/renew": { "/cert/renew": {
"post": { "get": {
"description": "Renew cert", "description": "Renew cert",
"consumes": [
"application/json"
],
"produces": [ "produces": [
"application/json" "text/plain"
], ],
"tags": [ "tags": [
"cert" "cert",
"websocket"
], ],
"summary": "Renew cert", "summary": "Renew cert",
"responses": { "responses": {
@@ -379,9 +374,6 @@ const docTemplate = `{
"/docker/containers": { "/docker/containers": {
"get": { "get": {
"description": "Get containers", "description": "Get containers",
"consumes": [
"application/json"
],
"produces": [ "produces": [
"application/json" "application/json"
], ],
@@ -418,9 +410,6 @@ const docTemplate = `{
"/docker/info": { "/docker/info": {
"get": { "get": {
"description": "Get docker info", "description": "Get docker info",
"consumes": [
"application/json"
],
"produces": [ "produces": [
"application/json" "application/json"
], ],
@@ -432,10 +421,7 @@ const docTemplate = `{
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "array", "$ref": "#/definitions/ServerInfo"
"items": {
"$ref": "#/definitions/ServerInfo"
}
} }
}, },
"403": { "403": {

View File

@@ -297,9 +297,6 @@
"/cert/info": { "/cert/info": {
"get": { "get": {
"description": "Get cert info", "description": "Get cert info",
"consumes": [
"application/json"
],
"produces": [ "produces": [
"application/json" "application/json"
], ],
@@ -338,16 +335,14 @@
} }
}, },
"/cert/renew": { "/cert/renew": {
"post": { "get": {
"description": "Renew cert", "description": "Renew cert",
"consumes": [
"application/json"
],
"produces": [ "produces": [
"application/json" "text/plain"
], ],
"tags": [ "tags": [
"cert" "cert",
"websocket"
], ],
"summary": "Renew cert", "summary": "Renew cert",
"responses": { "responses": {
@@ -377,9 +372,6 @@
"/docker/containers": { "/docker/containers": {
"get": { "get": {
"description": "Get containers", "description": "Get containers",
"consumes": [
"application/json"
],
"produces": [ "produces": [
"application/json" "application/json"
], ],
@@ -417,9 +409,6 @@
"/docker/info": { "/docker/info": {
"get": { "get": {
"description": "Get docker info", "description": "Get docker info",
"consumes": [
"application/json"
],
"produces": [ "produces": [
"application/json" "application/json"
], ],
@@ -431,10 +420,7 @@
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "array", "$ref": "#/definitions/ServerInfo"
"items": {
"$ref": "#/definitions/ServerInfo"
}
} }
}, },
"403": { "403": {

View File

@@ -437,11 +437,11 @@ definitions:
- 1mo - 1mo
type: string type: string
x-enum-comments: x-enum-comments:
MetricsPeriod1mo: '@name MetricsPeriod1mo'
MetricsPeriod5m: '@name MetricsPeriod5m'
MetricsPeriod15m: '@name MetricsPeriod15m' MetricsPeriod15m: '@name MetricsPeriod15m'
MetricsPeriod1d: '@name MetricsPeriod1d' MetricsPeriod1d: '@name MetricsPeriod1d'
MetricsPeriod1h: '@name MetricsPeriod1h' MetricsPeriod1h: '@name MetricsPeriod1h'
MetricsPeriod1mo: '@name MetricsPeriod1mo'
MetricsPeriod5m: '@name MetricsPeriod5m'
x-enum-varnames: x-enum-varnames:
- MetricsPeriod5m - MetricsPeriod5m
- MetricsPeriod15m - MetricsPeriod15m
@@ -1452,8 +1452,6 @@ paths:
x-id: logout x-id: logout
/cert/info: /cert/info:
get: get:
consumes:
- application/json
description: Get cert info description: Get cert info
produces: produces:
- application/json - application/json
@@ -1479,12 +1477,10 @@ paths:
- cert - cert
x-id: info x-id: info
/cert/renew: /cert/renew:
post: get:
consumes:
- application/json
description: Renew cert description: Renew cert
produces: produces:
- application/json - text/plain
responses: responses:
"200": "200":
description: OK description: OK
@@ -1501,11 +1497,10 @@ paths:
summary: Renew cert summary: Renew cert
tags: tags:
- cert - cert
- websocket
x-id: renew x-id: renew
/docker/containers: /docker/containers:
get: get:
consumes:
- application/json
description: Get containers description: Get containers
produces: produces:
- application/json - application/json
@@ -1530,8 +1525,6 @@ paths:
x-id: containers x-id: containers
/docker/info: /docker/info:
get: get:
consumes:
- application/json
description: Get docker info description: Get docker info
produces: produces:
- application/json - application/json
@@ -1539,9 +1532,7 @@ paths:
"200": "200":
description: OK description: OK
schema: schema:
items: $ref: '#/definitions/ServerInfo'
$ref: '#/definitions/ServerInfo'
type: array
"403": "403":
description: Forbidden description: Forbidden
schema: schema:
@@ -2124,11 +2115,11 @@ paths:
name: period name: period
type: string type: string
x-enum-comments: x-enum-comments:
MetricsPeriod1mo: '@name MetricsPeriod1mo'
MetricsPeriod5m: '@name MetricsPeriod5m'
MetricsPeriod15m: '@name MetricsPeriod15m' MetricsPeriod15m: '@name MetricsPeriod15m'
MetricsPeriod1d: '@name MetricsPeriod1d' MetricsPeriod1d: '@name MetricsPeriod1d'
MetricsPeriod1h: '@name MetricsPeriod1h' MetricsPeriod1h: '@name MetricsPeriod1h'
MetricsPeriod1mo: '@name MetricsPeriod1mo'
MetricsPeriod5m: '@name MetricsPeriod5m'
x-enum-varnames: x-enum-varnames:
- MetricsPeriod5m - MetricsPeriod5m
- MetricsPeriod15m - MetricsPeriod15m