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

Flasgger validate() function should accept empty data in body #336

Open
cesarferradas opened this issue Sep 19, 2019 · 0 comments
Open

Flasgger validate() function should accept empty data in body #336

cesarferradas opened this issue Sep 19, 2019 · 0 comments

Comments

@cesarferradas
Copy link
Contributor

@cesarferradas cesarferradas commented Sep 19, 2019

In a POST or PUT request, nothing in the HTTP protocol states that the request bodies should be non-empty. However, these two lines prevent an empty body from being sent if an API endpoint is being validated by Flasgger.

To give a concrete example: I have a JSON schema defined for an entity. All of its fields are optional, so you could send a POST request with {} and the endpoint should create a resource with the default values defined for the entity.

However, if the POST request is non-empty, I still want the body validated against my schema (e.g. with no additional properties, that the fields are the right type, etc).

Currently, if I send {}, [] or no body at all, I get a validation error "No data to validate".

Related: #293

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.