我无法想出如何在 node 中实现一个返回响应代码的 swagger(使用 swagger-node-express 项目)函数。
例如,对于此 swagger 路径:
/api/user/create:
x-swagger-router-controller: api
get:
operationId: userCreate
parameters:
- name: username
in: query
description: The username of the user.
required: true
type: string
- name: password
in: query
description: The password of the user.
required: true
type: string
- name: email
in: query
description: The email of the user.
required: true
type: string
responses:
'200':
description: OK
'412':
description: User already exists
I would like to send a return.
If I try
res.json(200);
或者
res.sendStatus(200);
甚至更多
res.sendStatus();
我遇到了这个错误:响应验证失败:void不允许有值。
如果我发送请求,Swagger编辑器将会出现解析错误。
res.json()
我遇到了一个“无法允许值”的错误。
我感觉已经没什么尝试的选项了,真的需要一些意见。
{"message":"响应验证失败:void不允许有值","code":"INVALID_TYPE","failedValidation":true,"path":["paths","/company/{companyName}","post","responses","200"],"originalResponse":"{}"}
- Ernst Robert