Closed cathywise closed 1 month ago
Thanks for the issue @cathywise! Sounds like I should be able to easily reproduce and fix. Thanks for trying out the new client! 🚀
Hey @cathywise, I've got a fix for this which I will publish shortly. There's no need to update the fetch client, fixing types worked for me, no more compiler problems (that is, unless I did NOT include the header which is the expected behaviour).
It's a bit of a naïve fix as it's not tested on multiple content types. If you'll still have problems, please open another issue. I just worry if that happens, it will take longer to resolve, because the types don't support multiple content types well. That's something I need to eventually improve, hopefully a worry for another day.
Pushed another update which uses JSON.stringify()
to convert the value when making the actual request. Please update both the client and @hey-api/openapi-ts
to the latest version and let me know if you run into more problems!
Thanks! The fix is working a treat 💟
Description
I have an OpenAPI spec where there is a custom header parameter in one of the requests, which is a JSON format. The generated type is however,
unknown
, which makes it tricky to use. In fact, when used with the client@hey-api/client-fetch
, the generated service code doesn't compile.For example, with the spec and config below, the
services.gen.ts
is:And in
types.gen.ts
is:This type isn't compatible with
RequestOptionsBase
. The full error from the compiler is:Please let me know if there's any more info I can provide to help!
OpenAPI specification (optional)
Configuration
System information (optional)
MacOS, Node v20.10.0, NPM 10.2.3