docs(api): update swagger documentation for admin endpoints

Reflect recent API changes in Swagger documentation:
- Add endpoints for feature flag management (/admin/features)
- Add endpoint for issuing child keys to masters (/admin/masters/{id}/keys)
- Add endpoint for updating providers (/admin/providers/{id})
- Update provider model definitions with new fields (auto_ban, google_* attributes, status)
This commit is contained in:
zenfun
2025-12-15 16:12:56 +08:00
parent aa69ce3659
commit ca03ac1b79
3 changed files with 685 additions and 0 deletions

View File

@@ -24,6 +24,86 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/admin/features": {
"get": {
"security": [
{
"AdminAuth": []
}
],
"description": "Returns all feature flags stored in Redis (meta:features)",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "List feature flags",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
},
"put": {
"security": [
{
"AdminAuth": []
}
],
"description": "Updates selected feature flags (meta:features). Values are stored as strings.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Update feature flags",
"parameters": [
{
"description": "Feature map",
"name": "request",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/masters": {
"post": {
"security": [
@@ -75,6 +155,76 @@ const docTemplate = `{
}
}
},
"/admin/masters/{id}/keys": {
"post": {
"security": [
{
"AdminAuth": []
}
],
"description": "Issue a new access token (child key) for a specified master. The key still belongs to the master; issuer is recorded as admin for audit.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Issue a child key on behalf of a master",
"parameters": [
{
"type": "integer",
"description": "Master ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Key Request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/internal_api.IssueChildKeyRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/models": {
"get": {
"security": [
@@ -273,6 +423,70 @@ const docTemplate = `{
}
}
},
"/admin/providers/{id}": {
"put": {
"security": [
{
"AdminAuth": []
}
],
"description": "Update provider attributes including status/auto-ban flags",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Update a provider",
"parameters": [
{
"type": "integer",
"description": "Provider ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Provider Info",
"name": "provider",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderDTO"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_model.Provider"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/sync/snapshot": {
"post": {
"security": [
@@ -448,9 +662,24 @@ const docTemplate = `{
"api_key": {
"type": "string"
},
"auto_ban": {
"type": "boolean"
},
"ban_reason": {
"type": "string"
},
"ban_until": {
"type": "string"
},
"base_url": {
"type": "string"
},
"google_location": {
"type": "string"
},
"google_project": {
"type": "string"
},
"group": {
"type": "string"
},
@@ -464,6 +693,13 @@ const docTemplate = `{
"name": {
"type": "string"
},
"skip_routing": {
"description": "Optional control params",
"type": "boolean"
},
"status": {
"type": "string"
},
"type": {
"type": "string"
}
@@ -577,6 +813,18 @@ const docTemplate = `{
"api_key": {
"type": "string"
},
"auto_ban": {
"description": "whether DP-triggered disable is allowed",
"type": "boolean"
},
"ban_reason": {
"description": "reason for current disable",
"type": "string"
},
"ban_until": {
"description": "optional TTL for disable",
"type": "string"
},
"base_url": {
"type": "string"
},
@@ -586,6 +834,12 @@ const docTemplate = `{
"deletedAt": {
"$ref": "#/definitions/gorm.DeletedAt"
},
"google_location": {
"type": "string"
},
"google_project": {
"type": "string"
},
"group": {
"description": "routing group/tier",
"type": "string"
@@ -600,6 +854,10 @@ const docTemplate = `{
"name": {
"type": "string"
},
"status": {
"description": "active, auto_disabled, manual_disabled",
"type": "string"
},
"type": {
"description": "openai, anthropic, etc.",
"type": "string"