113 lines
2.1 KiB
JavaScript
113 lines
2.1 KiB
JavaScript
/**
|
||
* 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: '用户信息'
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
};
|