1
This commit is contained in:
112
config/custom.schemas.js
Normal file
112
config/custom.schemas.js
Normal file
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* Swagger自定义Schema定义
|
||||
* 用于生成API文档的数据模型定义
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
// 通用响应格式
|
||||
ApiResponse: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
code: {
|
||||
type: 'integer',
|
||||
description: '状态码,200表示成功',
|
||||
example: 200
|
||||
},
|
||||
message: {
|
||||
type: 'string',
|
||||
description: '响应消息',
|
||||
example: '操作成功'
|
||||
},
|
||||
data: {
|
||||
type: 'object',
|
||||
description: '响应数据'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 分页响应格式
|
||||
PageResponse: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
code: {
|
||||
type: 'integer',
|
||||
example: 200
|
||||
},
|
||||
message: {
|
||||
type: 'string',
|
||||
example: '查询成功'
|
||||
},
|
||||
data: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
total: {
|
||||
type: 'integer',
|
||||
description: '总记录数'
|
||||
},
|
||||
pageSize: {
|
||||
type: 'integer',
|
||||
description: '每页记录数'
|
||||
},
|
||||
currentPage: {
|
||||
type: 'integer',
|
||||
description: '当前页码'
|
||||
},
|
||||
list: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object'
|
||||
},
|
||||
description: '数据列表'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 登录请求
|
||||
LoginRequest: {
|
||||
type: 'object',
|
||||
required: ['username', 'password'],
|
||||
properties: {
|
||||
username: {
|
||||
type: 'string',
|
||||
description: '用户名',
|
||||
example: 'admin'
|
||||
},
|
||||
password: {
|
||||
type: 'string',
|
||||
description: '密码',
|
||||
example: '123456'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 登录响应
|
||||
LoginResponse: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
code: {
|
||||
type: 'integer',
|
||||
example: 200
|
||||
},
|
||||
message: {
|
||||
type: 'string',
|
||||
example: '登录成功'
|
||||
},
|
||||
data: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
token: {
|
||||
type: 'string',
|
||||
description: 'JWT Token'
|
||||
},
|
||||
userInfo: {
|
||||
type: 'object',
|
||||
description: '用户信息'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user