Post endpoint's data object is typed to union of <SomeType> and <SomeType>[]
y-az opened this issue · 6 comments
Description
Hi! I'm trying out this package in combination with openapi-typescript. I found that when I tried to POST to my endpoint, let's say /categories
the type of data is Category
| Category[]
, which is weird to me because in my openapi schema, there is no reference to any array being returned from this POST call. What am I doing wrong here?
I'm experiencing pretty much the opposite. I have an endpoint that should only return Item[] but for some reason I get Item | Item[].
Edit: I just checked the post method on the same endpoint and it returns both as well. It seems everything at a certain path will have the return types of a union of all methods.
Just published a new version 0.1.0
that fixes several type bugs. Either it fixes this issue, or it at least fixes the blockers to fixing this. Would appreciate if people can try the new version and see if the issue persists.
If the issue is NOT fixed in the latest version, if you could please provide a minimal reproduction of the OpenAPI schema you’re using, I could investigate further.
The problem is still affecting me. I'll work on a reproduction example.
https://github.com/busheezy/openapi-fetch-type-error-reproduction-client
https://share.busheezy.dev/i/gWxxtq
Here is an example repo. Thanks!
This should be fixed in v0.1.1
! Thank you for the reproduction—that really helped!