orval-labs / orval

orval is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in yaml or json formats. 🍺
https://orval.dev
MIT License
3.18k stars 336 forks source link

(fix) add response headers in fetch client #1695

Closed melloware closed 1 week ago

melloware commented 2 weeks ago

Fix #1694 add response headers in fetch client

soartec-lab commented 2 weeks ago

Hi @melloware, Please give me some time to think about this response.

melloware commented 2 weeks ago

Yep converting to draft was just seeing if that is what the OP meant!

nimo23 commented 1 week ago

@melloware Thanks, the PR looks good to me. I think Orval doesn't need to check to add the headers to the response only when custom headers are detected in openapi.yaml. Headers should be included by default.

melloware commented 1 week ago

@soartec-lab you are more familiar with this code did you want to submit a PR and I can close this one?

melloware commented 1 week ago

OK changes made

soartec-lab commented 1 week ago

@melloware

Thanks! can you regenerate the fetch client and update the custom-fetch implement in sample apps ?

melloware commented 1 week ago

@soartec-lab not sure what you mean by regenerate but i updated orval.config.js and custom-fetch.js in samples directory.

soartec-lab commented 1 week ago

@melloware

Sorry for confusing you. To be more precise, I would like you to regenerate the sample app using the following command.

cd samples
yarn generate-api --force

Your change adds headers to returnType, so the returnType of the sample app generated by orval should also be updated.

melloware commented 1 week ago

Weird when I run that command in samples I get..

 Tasks:    0 successful, 21 total
Cached:    0 cached, 21 total
  Time:    1.957s
Failed:    react-query-basic#generate-api, react-query-form-data#generate-api, react-query-form-url-encoded#generate-api

 ERROR  run failed: command  exited (1)
melloware commented 1 week ago

Would you like to just merge this PR and then you can take a look?

soartec-lab commented 1 week ago

@melloware Can I run it and put commits on this branch ?

melloware commented 1 week ago

Oh sure thing my branch should be editable for you!

soartec-lab commented 1 week ago

@melloware Can you try cherry-pick this ?

https://github.com/orval-labs/orval/pull/1699/commits/13533d5d1e8ab2776653c642547cfe65419855c3

Or if you like, you can switch to this PR.

https://github.com/orval-labs/orval/pull/1699