openapi-typescript-fetch icon indicating copy to clipboard operation
openapi-typescript-fetch copied to clipboard

feat: Explode query string

Open duncanbeevers opened this issue 3 years ago • 1 comments
trafficstars

🐸 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.

duncanbeevers avatar Sep 06 '22 22:09 duncanbeevers

👋

is this library still being maintained ?

NicoGrapsasWK avatar Jan 25 '23 18:01 NicoGrapsasWK