orval icon indicating copy to clipboard operation
orval copied to clipboard

`urlEncodeParameters` config ignored when using `fetch`

Open yadyn opened this issue 6 months ago • 1 comments

The output config urlEncodeParameters says it is only supported in Tanstack Query clients and that is true but it additionally only works if your httpClient is set to axios (the default). Changing httpClient to fetch makes the setting no longer do anything.

Near as I can tell, this problem was introduced in the v7.x release when fetch support was added for Tanstack Query clients. The code was split, and the original axios implementation retained the fix from #679, but the fetch implementation does not use it.

You can easily reproduce this in the playground.

  1. Choose the Basic example
  2. Find the showPetById function in endpoints.ts and note that is not encoding the petId param in the route
  3. Add the line "urlEncodeParameters": true to orval.config.ts under the "output" section
  4. Find the showPetById function in endpoints.ts again and note that it now properly wraps petId with encodeURIComponent, awesome!
  5. Add the line "httpClient": "fetch", to orval.config.ts under the "output" section
  6. Find the getShowPetByIdUrl function in endpoints.ts and note that it does not encode the petId param in the route
  7. You can change or remove urlEncodeParameters but the output won't differ as the code that generates for fetch never uses it

yadyn avatar Jun 18 '25 20:06 yadyn

Seems like it just needs to be implemented for Fetch. PR is welcome.

melloware avatar Jun 19 '25 00:06 melloware

I can give it a look tomorrow @melloware

chcederquist avatar Aug 06 '25 12:08 chcederquist

Assigned to you thanks!

melloware avatar Aug 06 '25 12:08 melloware