koa-swagger-decorator
koa-swagger-decorator copied to clipboard
body参数校验失败
ts项目中设置body中的参数为required:true,并没有生效
Hello,
I encountered the same problem.
required
in @body
is skipped.
With debugger, I looked and in node-modules/koa-swagger-decorator/lib/validate/index.ts
, line 19, the expect
variable is:
{
firstName: { type: "string" }
}
but my declared schema is
@body({
firstName: { type: "string", required: true }
})
@query
and @path
are working correctly.
Looking at previous PR, I believe this is the PR that actually strips required
field in @body
: https://github.com/Cody2333/koa-swagger-decorator/pull/112 and prevents the validation for required fields.
Might need to reconstruct the correct expect object or for body validate based on required swagger definition
This can be closed as the new version now correctly validates the body of the requests.