fix: swagger

This commit is contained in:
2025-12-16 17:11:49 +08:00
parent 0e303e8a5c
commit 9bc2155008
16 changed files with 998 additions and 704 deletions

View File

@@ -24,6 +24,133 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/super/v1/auth/login": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Super"
],
"parameters": [
{
"description": "form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.LoginForm"
}
}
],
"responses": {
"200": {
"description": "成功",
"schema": {
"$ref": "#/definitions/dto.LoginResponse"
}
}
}
}
},
"/super/v1/tenants": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Super"
],
"summary": "租户列表",
"parameters": [
{
"type": "string",
"name": "asc",
"in": "query"
},
{
"type": "string",
"name": "desc",
"in": "query"
},
{
"type": "integer",
"name": "limit",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "integer",
"name": "page",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/requests.Pager"
},
{
"type": "object",
"properties": {
"items": {
"$ref": "#/definitions/dto.TenantItem"
}
}
}
]
}
}
}
}
},
"/super/v1/tenants/{tenantID}": {
"patch": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Super"
],
"summary": "更新过期时间",
"parameters": [
{
"type": "integer",
"format": "int64",
"description": "TenantID",
"name": "tenantID",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.TenantExpireUpdateForm"
}
}
],
"responses": {}
}
},
"/v1/medias/{id}": {
"post": {
"description": "Test",
@@ -92,6 +219,238 @@ const docTemplate = `{
}
},
"definitions": {
"consts.Role": {
"type": "string",
"enum": [
"user",
"super_admin"
],
"x-enum-varnames": [
"RoleUser",
"RoleSuperAdmin"
]
},
"consts.TenantStatus": {
"type": "string",
"enum": [
"pending_verify",
"verified",
"banned"
],
"x-enum-varnames": [
"TenantStatusPendingVerify",
"TenantStatusVerified",
"TenantStatusBanned"
]
},
"consts.UserStatus": {
"type": "string",
"enum": [
"pending_verify",
"verified",
"banned"
],
"x-enum-varnames": [
"UserStatusPendingVerify",
"UserStatusVerified",
"UserStatusBanned"
]
},
"dto.LoginForm": {
"type": "object",
"properties": {
"password": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"dto.LoginResponse": {
"type": "object",
"properties": {
"token": {
"type": "string"
}
}
},
"dto.TenantExpireUpdateForm": {
"type": "object",
"required": [
"duration"
],
"properties": {
"duration": {
"type": "integer",
"enum": [
7,
30,
90,
180,
365
]
}
}
},
"dto.TenantItem": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"config": {
"type": "array",
"items": {
"type": "integer"
}
},
"created_at": {
"type": "string"
},
"expired_at": {
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"status": {
"$ref": "#/definitions/consts.TenantStatus"
},
"updated_at": {
"type": "string"
},
"userBalance": {
"type": "integer",
"format": "int64"
},
"userCount": {
"type": "integer",
"format": "int64"
},
"user_id": {
"type": "integer"
},
"users": {
"type": "array",
"items": {
"$ref": "#/definitions/models.User"
}
},
"uuid": {
"type": "string"
}
}
},
"gorm.DeletedAt": {
"type": "object",
"properties": {
"time": {
"type": "string"
},
"valid": {
"description": "Valid is true if Time is not NULL",
"type": "boolean"
}
}
},
"models.Tenant": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"config": {
"type": "array",
"items": {
"type": "integer"
}
},
"created_at": {
"type": "string"
},
"expired_at": {
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"status": {
"$ref": "#/definitions/consts.TenantStatus"
},
"updated_at": {
"type": "string"
},
"user_id": {
"type": "integer"
},
"users": {
"type": "array",
"items": {
"$ref": "#/definitions/models.User"
}
},
"uuid": {
"type": "string"
}
}
},
"models.User": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"deleted_at": {
"$ref": "#/definitions/gorm.DeletedAt"
},
"id": {
"type": "integer"
},
"metas": {
"type": "array",
"items": {
"type": "integer"
}
},
"owned": {
"$ref": "#/definitions/models.Tenant"
},
"password": {
"type": "string"
},
"roles": {
"type": "array",
"items": {
"$ref": "#/definitions/consts.Role"
}
},
"status": {
"$ref": "#/definitions/consts.UserStatus"
},
"tenants": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Tenant"
}
},
"updated_at": {
"type": "string"
},
"username": {
"type": "string"
},
"verified_at": {
"type": "string"
}
}
},
"requests.Pager": {
"type": "object",
"properties": {
@@ -126,7 +485,7 @@ const docTemplate = `{
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "localhost:8080",
BasePath: "/api/v1",
BasePath: "/t/{tenant_code}/v1",
Schemes: []string{},
Title: "ApiDoc",
Description: "This is a sample server celler server.",

View File

@@ -16,8 +16,135 @@
"version": "1.0"
},
"host": "localhost:8080",
"basePath": "/api/v1",
"basePath": "/t/{tenant_code}/v1",
"paths": {
"/super/v1/auth/login": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Super"
],
"parameters": [
{
"description": "form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.LoginForm"
}
}
],
"responses": {
"200": {
"description": "成功",
"schema": {
"$ref": "#/definitions/dto.LoginResponse"
}
}
}
}
},
"/super/v1/tenants": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Super"
],
"summary": "租户列表",
"parameters": [
{
"type": "string",
"name": "asc",
"in": "query"
},
{
"type": "string",
"name": "desc",
"in": "query"
},
{
"type": "integer",
"name": "limit",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "integer",
"name": "page",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/requests.Pager"
},
{
"type": "object",
"properties": {
"items": {
"$ref": "#/definitions/dto.TenantItem"
}
}
}
]
}
}
}
}
},
"/super/v1/tenants/{tenantID}": {
"patch": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Super"
],
"summary": "更新过期时间",
"parameters": [
{
"type": "integer",
"format": "int64",
"description": "TenantID",
"name": "tenantID",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.TenantExpireUpdateForm"
}
}
],
"responses": {}
}
},
"/v1/medias/{id}": {
"post": {
"description": "Test",
@@ -86,6 +213,238 @@
}
},
"definitions": {
"consts.Role": {
"type": "string",
"enum": [
"user",
"super_admin"
],
"x-enum-varnames": [
"RoleUser",
"RoleSuperAdmin"
]
},
"consts.TenantStatus": {
"type": "string",
"enum": [
"pending_verify",
"verified",
"banned"
],
"x-enum-varnames": [
"TenantStatusPendingVerify",
"TenantStatusVerified",
"TenantStatusBanned"
]
},
"consts.UserStatus": {
"type": "string",
"enum": [
"pending_verify",
"verified",
"banned"
],
"x-enum-varnames": [
"UserStatusPendingVerify",
"UserStatusVerified",
"UserStatusBanned"
]
},
"dto.LoginForm": {
"type": "object",
"properties": {
"password": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"dto.LoginResponse": {
"type": "object",
"properties": {
"token": {
"type": "string"
}
}
},
"dto.TenantExpireUpdateForm": {
"type": "object",
"required": [
"duration"
],
"properties": {
"duration": {
"type": "integer",
"enum": [
7,
30,
90,
180,
365
]
}
}
},
"dto.TenantItem": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"config": {
"type": "array",
"items": {
"type": "integer"
}
},
"created_at": {
"type": "string"
},
"expired_at": {
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"status": {
"$ref": "#/definitions/consts.TenantStatus"
},
"updated_at": {
"type": "string"
},
"userBalance": {
"type": "integer",
"format": "int64"
},
"userCount": {
"type": "integer",
"format": "int64"
},
"user_id": {
"type": "integer"
},
"users": {
"type": "array",
"items": {
"$ref": "#/definitions/models.User"
}
},
"uuid": {
"type": "string"
}
}
},
"gorm.DeletedAt": {
"type": "object",
"properties": {
"time": {
"type": "string"
},
"valid": {
"description": "Valid is true if Time is not NULL",
"type": "boolean"
}
}
},
"models.Tenant": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"config": {
"type": "array",
"items": {
"type": "integer"
}
},
"created_at": {
"type": "string"
},
"expired_at": {
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"status": {
"$ref": "#/definitions/consts.TenantStatus"
},
"updated_at": {
"type": "string"
},
"user_id": {
"type": "integer"
},
"users": {
"type": "array",
"items": {
"$ref": "#/definitions/models.User"
}
},
"uuid": {
"type": "string"
}
}
},
"models.User": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"deleted_at": {
"$ref": "#/definitions/gorm.DeletedAt"
},
"id": {
"type": "integer"
},
"metas": {
"type": "array",
"items": {
"type": "integer"
}
},
"owned": {
"$ref": "#/definitions/models.Tenant"
},
"password": {
"type": "string"
},
"roles": {
"type": "array",
"items": {
"$ref": "#/definitions/consts.Role"
}
},
"status": {
"$ref": "#/definitions/consts.UserStatus"
},
"tenants": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Tenant"
}
},
"updated_at": {
"type": "string"
},
"username": {
"type": "string"
},
"verified_at": {
"type": "string"
}
}
},
"requests.Pager": {
"type": "object",
"properties": {

View File

@@ -1,5 +1,163 @@
basePath: /api/v1
basePath: /t/{tenant_code}/v1
definitions:
consts.Role:
enum:
- user
- super_admin
type: string
x-enum-varnames:
- RoleUser
- RoleSuperAdmin
consts.TenantStatus:
enum:
- pending_verify
- verified
- banned
type: string
x-enum-varnames:
- TenantStatusPendingVerify
- TenantStatusVerified
- TenantStatusBanned
consts.UserStatus:
enum:
- pending_verify
- verified
- banned
type: string
x-enum-varnames:
- UserStatusPendingVerify
- UserStatusVerified
- UserStatusBanned
dto.LoginForm:
properties:
password:
type: string
username:
type: string
type: object
dto.LoginResponse:
properties:
token:
type: string
type: object
dto.TenantExpireUpdateForm:
properties:
duration:
enum:
- 7
- 30
- 90
- 180
- 365
type: integer
required:
- duration
type: object
dto.TenantItem:
properties:
code:
type: string
config:
items:
type: integer
type: array
created_at:
type: string
expired_at:
type: string
id:
type: integer
name:
type: string
status:
$ref: '#/definitions/consts.TenantStatus'
updated_at:
type: string
user_id:
type: integer
userBalance:
format: int64
type: integer
userCount:
format: int64
type: integer
users:
items:
$ref: '#/definitions/models.User'
type: array
uuid:
type: string
type: object
gorm.DeletedAt:
properties:
time:
type: string
valid:
description: Valid is true if Time is not NULL
type: boolean
type: object
models.Tenant:
properties:
code:
type: string
config:
items:
type: integer
type: array
created_at:
type: string
expired_at:
type: string
id:
type: integer
name:
type: string
status:
$ref: '#/definitions/consts.TenantStatus'
updated_at:
type: string
user_id:
type: integer
users:
items:
$ref: '#/definitions/models.User'
type: array
uuid:
type: string
type: object
models.User:
properties:
created_at:
type: string
deleted_at:
$ref: '#/definitions/gorm.DeletedAt'
id:
type: integer
metas:
items:
type: integer
type: array
owned:
$ref: '#/definitions/models.Tenant'
password:
type: string
roles:
items:
$ref: '#/definitions/consts.Role'
type: array
status:
$ref: '#/definitions/consts.UserStatus'
tenants:
items:
$ref: '#/definitions/models.Tenant'
type: array
updated_at:
type: string
username:
type: string
verified_at:
type: string
type: object
requests.Pager:
properties:
items: {}
@@ -29,6 +187,84 @@ info:
title: ApiDoc
version: "1.0"
paths:
/super/v1/auth/login:
post:
consumes:
- application/json
parameters:
- description: form
in: body
name: form
required: true
schema:
$ref: '#/definitions/dto.LoginForm'
produces:
- application/json
responses:
"200":
description: 成功
schema:
$ref: '#/definitions/dto.LoginResponse'
tags:
- Super
/super/v1/tenants:
get:
consumes:
- application/json
parameters:
- in: query
name: asc
type: string
- in: query
name: desc
type: string
- in: query
name: limit
type: integer
- in: query
name: name
type: string
- in: query
name: page
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/requests.Pager'
- properties:
items:
$ref: '#/definitions/dto.TenantItem'
type: object
summary: 租户列表
tags:
- Super
/super/v1/tenants/{tenantID}:
patch:
consumes:
- application/json
parameters:
- description: TenantID
format: int64
in: path
name: tenantID
required: true
type: integer
- description: Form
in: body
name: form
required: true
schema:
$ref: '#/definitions/dto.TenantExpireUpdateForm'
produces:
- application/json
responses: {}
summary: 更新过期时间
tags:
- Super
/v1/medias/{id}:
post:
consumes: