所以我使用
fastify.route
创建了一条 fastify 路线。但我无法在响应中返回 201
statusCode。即使我返回 201 statusCode,它也会转换为 200 。
fastify.route({
method: 'GET',
url: '/',
schema: {
querystring: {
name: { type: 'string' },
excitement: { type: 'integer' }
},
response: {
200: {
type: 'object',
properties: {
hello: { type: 'string' }
}
}
}
},
handler: function (request, reply) {
reply.send({ hello: 'world' })
}
})
¶
我指的是 swagger 的代码
response: {
200: {
type: 'object',
properties: {
hello: { type: 'string' }
}
}
}
这里我想用 201 替换 200,并给出必填字段,但似乎并没有像想象中那样抛出错误
这搞乱了我的发帖请求。
我有同样的问题,似乎FastifySchema只支持200序列化并给出成功的响应