-
-
Notifications
You must be signed in to change notification settings - Fork 660
feat: add new acceptNonStandardSearchParameters
MockAgent option
#4148
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
feat: add new acceptNonStandardSearchParameters
MockAgent option
#4148
Conversation
97cee8d
to
6d9cb9d
Compare
cf7daab
to
2eb2cb1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Actually, can you add docs for this? |
2eb2cb1
to
c8abf9e
Compare
ok docs added 🙂 c8abf9e It was much quicker than I thought 😄, I was initially thinking of adding an example for this but it feels like a bit of an overkill to me right now 🤔, please let me know what you think 🙂 |
add a new `acceptNonStandardSearchParameters` option to make instances of `MockAgent` accept search parameters specified using non-standard syntaxes such as multi-value items specified with `[]` (e.g. `param[]=1¶m[]=2¶m[]=3`) and multi-value items which values are comma separated (e.g. `param=1,2,3`) Co-authored-by: Carlos Fuentes <me@metcoder.dev>
c8abf9e
to
36356b1
Compare
acceptNonStandardSearchParameters
MockAgent option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Rationale
This PR adds a new
acceptNonStandardSearchParameters
option to makeinstances of
MockAgent
accept search parameters specifiedusing non-standard syntaxes such as multi-value items specified with
[]
(e.g.
param[]=1¶m[]=2¶m[]=3
) and multi-value items which valuesare comma separated (e.g.
param=1,2,3
)With these changes
MockAgent
instances can be enabled to intercept requestssuch as
https://example.com/qux-c?arraykey[]=a&arraykey[]=b
, etc...Changes
MockAgents created with the
acceptNonStandardSearchParameters
"normalize" requests such ashttps://example.com/qux-c?arraykey[]=a&arraykey[]=b
into ones likehttps://example.com/qux-c?arraykey=a&arraykey=b
so that they can then be handled normallyFeatures
N/A
Bug Fixes
Fixes #4146
Breaking Changes and Deprecations
None
Status
Note
My implementation supports the case of array values having
[]
(e.g.a[]=1,a[]=2,a[]=3
) and also different array values separated by commas (e.g.a=1,2,3
) and that's pretty much it, it could potentially support other syntaxes like the JSON API and Bitbucket API mentioned in https://medium.com/raml-api/arrays-in-query-params-33189628fa68, but that feels to me like quite an overkill right now. I am thinking that probably the cases I am adding support for now should cover most use cases anyways and if the extra ones will be needed in the future (someone opening an issue, etc...) they can always be incrementally added as needed on top of my changes 🤔