-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response body #8
Comments
Hi! You're right, extracting response types automatically in runtime isn't allowed by Typescript's reflection system ATM. Specifically the problem is we can't unwrap generic types like As for manually describing response types there's the
I understand there's still a bit of boilerplate involved, so you might want to write another decorator that just takes the name of the schema as a string and expands into the above One step further would be to write a decorator that takes any class-validator decorated class as a parameter, converts it into JSON schema and expands it into the above I'll probably see to implementing the latter at some point, but writing it yourself will definitely be quicker! 😉 |
Hi @epiphone ! Thanks for the very extensive and helpful reply! If you want I can ofc try to understand what I might have done to lead to below exception, but maybe this is something which only takes you a minute to understand. Just ping back if you dont feel like looking at a half-finished PR which I could understand :-)
|
Published in |
As I understand, this only works if I have a class for the response schema, but what if I want to define my own schema without create a new class. I could do it in this way:
In this way I can see the Schema |
@ricardo-dlc you can define a new decorator function that uses |
As far as I understand it is currently not possible to extract the response body automatically from type of the returned value in the controller./action.
Is there a way to describe it manually? In particular in many cases the definition of the response object is already present in the openapi-doc as it was used as request body in another action (think model-DTO being used as request for updateModel-PUT action and as response for getModel-GET action.
So it would be amazing not having to duplicate the type definitions in actual code as well as inside the @openapi decorator.
Thanks!
The text was updated successfully, but these errors were encountered: