Closed gdelory closed 8 months ago
Hello there gdelory š
Thank you for opening your very first issue in this project.
We will try to get back to you as soon as we can.š
I think this can not really be well documented via OpenAPI either way. From a pure TS perspective, generic is fine here, but to compile down into a spec, the union is what you want.
So, in short, this is the best way right now.
@WoH I completely agree with you, I just opened this issue to save time to future users having the same issue. In short, don't use conditional return type since it doesn't make sense (doesn't exist) anyway with OpenAPI, just stick to a union type for the return.
Closing this. Sorry, I should have done so right away, this was more meant as documentation for others š Thanks a lot for taking the time to answer, and your library is awesome, we had a really good experience with it so far, and I'll be happy to try to contribute if I have the opportunity in the future.
Hi all, I thought I would open a bug, then saw that what I was trying to do simply doesn't exist in OpenApi doc (here). To save some time to others, and because I searched the issues and there is nothing about generic controller's methods, I thought I would sill open/close this issue so other can find it š
I was trying to migrate some basic express code we had which returns different types based on a query param. I could make the return type a union of both types, of course. But I tried to be smart and apply condition return type like I usually do with other normal (none tsoa) functions.
And this fails with the following error:
Maybe instead of crashing, it would be possible to create a union type and output an
anyOf
in the swagger doc?Anyway, if anyone encounter this, since openapi doesn't support it, it's just easier to switch back to a union type:
I'm submitting a ...
I confirm that I