Add tests and fix parameter exploding issue#576
Open
hamir-suspect wants to merge 2 commits intoopen-api-spex:masterfrom
Open
Add tests and fix parameter exploding issue#576hamir-suspect wants to merge 2 commits intoopen-api-spex:masterfrom
hamir-suspect wants to merge 2 commits intoopen-api-spex:masterfrom
Conversation
Contributor
Author
|
This PR resolves #573 , I would welcome any suggestions for improvements. |
Collaborator
|
Thanks for the PR @hamir-suspect, I'm a bit concerned about the complexity required to identify all potential parameters that may apply to an exploded form style query parameter object. Could we simplify the approach by taking all query params, then remove those with names matching non-exploded Parameters? All remaining query params are potentially consumed by exploded Parameters and will be passed along to |
Contributor
Author
|
@mbuhot thanks for the feedback. I've cleaned up the PR a little bit and removed params with names matching to non-exploded schema parameters. |
a85bef6 to
8683985
Compare
8683985 to
e8f2137
Compare
This was referenced Jan 3, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
:someparameter.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]=yand 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.