[JavaScript] 纯文本查看 复制代码
/**
* @swagger
* /logger/apps:
* get:
* summary: 获取有日志记录的应用
* description: 获取有日志记录的应用
* tags:
* - Logger
* parameters:
* - name: appName
* in: query
* required: true
* description: 应用名称
* type: string
* - name: userId
* in: query
* required: true
* description: 用户id
* type: string
* responses:
* 200:
* description: 成功获取
*/
router.get('/apps', async (req, res, next) => {
try {
const result = ['自定义字段'];
return res.send({ result });
} catch (err) {
next(err);
}
});
[JavaScript] 纯文本查看 复制代码
// 定义可复用的schema
const userSchema = {
type: 'object',
properties: {
name: { type: 'string' },
gender: { type: 'string' }
}
};
@request('post', '/users')
@tag('User')
@summary('创建用户')
@body([{
name: 'data',
description: '用户信息',
schema: userSchema,
}])
static async postUser(ctx) {
const body = ctx.request.body;
...
ctx.body = { result: body };
}