Skip to content

Conversation

@duncanbeevers
Copy link

🐸 Problem to Solve

OpenAPI 3 accepts parameters whose schema is an object.
When passing data to a fetch function, nested query values get stringified as [object Object].

👑 Solution

This change extends the existing query params encoder.
It can now express nested objects and arrays in addition to scalar values.

It uses the form-style query parameter encoding which is the default style for query parameters.

image

🔧 Changes (and non-Changes)

  • scalars are encoded as before
  • lists are still exploded; however…
  • lists are exploded recursively
  • objects are exploded recursively

I included a bunch of examples in the tests for the src/explodeQueryFormStyle.ts utility.
I also added validation of url-encoding behavior in the fetcher tests.

OpenAPI 3 accepts parameters whose schema is an object
When specified, these parameters can be `in: query`
Such parameters can specify a style used to express them in the URL
The default style for `in: query` parameters is `form`
`form`-style parameters are expressed with a parameter-per-terminal value in the query object

This change extends the existing query params encoder.
It can now express nested objects and arrays in addition to scalar values
@duncanbeevers duncanbeevers force-pushed the feat/form-encode-query-params branch from daa6639 to 9647277 Compare December 8, 2022 16:28
@NicoGrapsasWK
Copy link

NicoGrapsasWK commented Jan 25, 2023

👋

is this library still being maintained ?

@Rendez Rendez mentioned this pull request Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants