Enable handling exploded parameters and test for edge cases #166
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.
Description
OpenAPI supports exploded array parameters, such as
stuff[]=foo&stuff[]=bar
. However, when operating in a Rails environment (or any other server environment which parses these exploded parameters into a singlestuff
field), parameter_validation fails to find the param properly, leading to erroneous missed required fields or just lack of validation.This was mentioned in the same Committee issue that is linked in #122 which has a PR to close that does not account for this specific scenario.
I originally thought this was possibly something that should be solved on the Committee side, but it looks like they are simply passing through to the validation here, and a referenced monkeypatch to this works, but that is not nearly as defensive and it seems like this should be a core support here.
This PR introduces handling for this, looking first for the param with the
[]
as it normally would, in case we are in an environment where they are not stripped. It then checks non-header parameters that end with[]
for a matching param that strips it.Monkeypatch