Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

body参数校验失败 #136

Open
sunyf1 opened this issue Oct 22, 2021 · 3 comments
Open

body参数校验失败 #136

sunyf1 opened this issue Oct 22, 2021 · 3 comments

Comments

@sunyf1
Copy link

sunyf1 commented Oct 22, 2021

ts项目中设置body中的参数为required:true,并没有生效

@paoesco
Copy link

paoesco commented Mar 31, 2022

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.

@paoesco
Copy link

paoesco commented Mar 31, 2022

Looking at previous PR, I believe this is the PR that actually strips required field in @body: #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

@paoesco
Copy link

paoesco commented Jul 1, 2022

This can be closed as the new version now correctly validates the body of the requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants