Add tests and fix parameter exploding issue #576
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.
This fixes the parameters exploding issue. Now parameters defined as:
will be properly casted into the
:some
parameter.How this works:
the parameters that we fetch for a location can be flat (
?foo=x&bar=y
) before casting we search for any parameters that should be exploded, if we find any we gather all the properties it can hold.We add those to the struct (as if it was a deep struct param
?some[foo]=x&some[bar]=y
and remove them from the query params. in the end query params struct before casting looks like%{"some" => %{"foo" => "x", "bar" => "y"}}
instead of what we started with:%{"foo" => "x", "bar" => "y"}
.The ideal way would be to fix how the location schema is composed but that seems to be quite tricky with current implementation.
The PR has some leftover code from experimentation, if you think this is a good solution I will clean it up.