orval-labs/orval

Documentation mistake

Closed this issue · 5 comments

Ran into an issue whereby my requests were missing a ? for any requests containing query parameters. I traced the issue back to this chunk of code I copied from the documentation, which is missing a question mark when constructing the URL. This issue is potentially responsible for: #482

`${baseURL}${url}` + new URLSearchParams(params),

What versions are you using?

Checked on master
Please execute npx envinfo --system --npmPackages orval,zod,axios,msw,swr,@tanstack/react-query,@tanstack/vue-query,react,vue and paste the results here.

Can you post your exact fix? missing question mark where?

Replacing:

${baseURL}${url}

With:

${baseURL}${url}?

Solved the issue since URLSearchParams doesn't generate a leading question mark when stringified.

Note that this isn't necessarily the ideal solution since requests without query parameters will end up with a trailing question mark - ideally there should be a check beforehand to ensure there are query parameters.

Happy to create a PR if that would be easiest :)

please do! I will merge it

Assigned it to you.