Files
go-skeleton/docs/swagger.json
T

410 lines
13 KiB
JSON

{
"swagger": "2.0",
"info": {
"description": "Skeleton API documentation.",
"title": "Skeleton API",
"contact": {},
"version": "0.1.0"
},
"basePath": "/api",
"paths": {
"/auth/login": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "用户登录",
"parameters": [
{
"description": "登录信息",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/auth.Credentials"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/utils.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/middlewares.TokenPair"
}
}
}
]
}
}
}
}
},
"/auth/refresh": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "刷新并轮换 Token",
"parameters": [
{
"description": "Refresh Token",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/auth.RefreshRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/utils.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/middlewares.TokenPair"
}
}
}
]
}
}
}
}
},
"/auth/register": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "注册示例用户",
"parameters": [
{
"description": "注册信息",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/auth.Credentials"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/utils.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.UserResponse"
}
}
}
]
}
}
}
}
},
"/example/hello": {
"get": {
"produces": [
"application/json"
],
"tags": [
"example"
],
"summary": "返回示例消息",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/utils.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/example.HelloResponse"
}
}
}
]
}
}
}
}
},
"/health": {
"get": {
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "服务健康检查",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/rest.systemResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/rest.healthData"
}
}
}
]
}
},
"503": {
"description": "Service Unavailable",
"schema": {
"allOf": [
{
"$ref": "#/definitions/rest.systemResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/rest.healthData"
}
}
}
]
}
}
}
}
},
"/ping": {
"get": {
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "服务连通性检查",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/rest.systemResponse"
}
}
}
}
},
"/private/auth/logout": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "注销并撤销 Token",
"parameters": [
{
"description": "可选 Refresh Token",
"name": "body",
"in": "body",
"schema": {
"$ref": "#/definitions/auth.LogoutRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/utils.APIResponse"
}
}
}
}
}
},
"definitions": {
"auth.Credentials": {
"type": "object",
"required": [
"password",
"username"
],
"properties": {
"password": {
"type": "string",
"maxLength": 72,
"minLength": 8,
"example": "change-me-123"
},
"username": {
"type": "string",
"maxLength": 64,
"minLength": 3,
"example": "demo"
}
}
},
"auth.LogoutRequest": {
"type": "object",
"properties": {
"refresh_token": {
"type": "string"
}
}
},
"auth.RefreshRequest": {
"type": "object",
"required": [
"refresh_token"
],
"properties": {
"refresh_token": {
"type": "string"
}
}
},
"auth.UserResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"username": {
"type": "string"
}
}
},
"example.HelloResponse": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
},
"middlewares.TokenPair": {
"type": "object",
"properties": {
"access_token": {
"type": "string"
},
"expires_in": {
"type": "integer",
"example": 900
},
"refresh_token": {
"type": "string"
},
"token_type": {
"type": "string",
"example": "Bearer"
}
}
},
"rest.healthData": {
"type": "object",
"properties": {
"database": {
"type": "string"
},
"redis": {
"type": "string"
},
"status": {
"type": "string"
}
}
},
"rest.systemResponse": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"example": 200
},
"data": {},
"message": {
"type": "string"
}
}
},
"utils.APIResponse": {
"type": "object",
"properties": {
"code": {
"type": "integer"
},
"data": {},
"message": {
"type": "string"
}
}
}
},
"securityDefinitions": {
"BearerAuth": {
"description": "输入 Bearer {token}",
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
}
}