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

Fail on additionalProperties? #2410

Open
Marclev78 opened this issue Oct 6, 2020 · 2 comments
Open

Fail on additionalProperties? #2410

Marclev78 opened this issue Oct 6, 2020 · 2 comments

Comments

@Marclev78
Copy link

Problem statement

I want my server to reject requests where the body includes unknown properties. In json-schema I would typically do this with additional-properties=false. However according to https://goswagger.io/use/models/schemas.html go-swagger's model will simply strip such additional properties out instead of rejecting the request.

Is there anyway to instruct the generated code to fail validation if additional properties are detected, instead of ignoring them?

@casualjim
Copy link
Member

You can make a middleware that does that in front, but we don't support that directly, in the generated code

@fredbi
Copy link
Contributor

fredbi commented Nov 14, 2020

@Marclev78 You can try to generate your server with the --strict-additional-properties flag.
There are some corner cases with that option, but it should basically cover what you want.

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