fix(oas3): request body validation #9698
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refs #9673
Request body with content type
application/json
should now correctly validate missing required values and incorrect value types, and show errors.I had an issue with making it work for
application/x-www-form-urlencoded
. I could validate types, which was missing before, but empty values would incorrectly show errors if the parameter type was different thanstring
. This is because the value would be an empty string then, and the method would see that as an error. As such, I went back to the version that worked forapplication/json
for now.There is also one e2e test that will not pass, because it expects that a request body with a single space
" "
will be validated as correct. With my changes it's as invalid JSON:I'm not sure if I should update the test or if the previous behaviour was correct, and I should change the validation.