Skip to content
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

add response body example to responses #153

Open
GalTidhar-Deliverr opened this issue Feb 6, 2022 · 1 comment
Open

add response body example to responses #153

GalTidhar-Deliverr opened this issue Feb 6, 2022 · 1 comment

Comments

@GalTidhar-Deliverr
Copy link

is there a way to define the response body? it's not apart of the interface

@GalTidhar-Deliverr
Copy link
Author

GalTidhar-Deliverr commented Feb 7, 2022

found a solution, not pretty but no code duplication is needed , should be either a feature or a part of the documentation
the documentation shows how to setup a scheme for the incoming body in the following way
@body((UserInfo as any).swaggerDocument
this does not work for responses, in order to return the same scheme in the response a it needs to be wrapped, i assume it's a bug and another .swaggerDocument named .swaggerResponseDocument should be created
i've created the following utility to encapsulate the 'hack'
`const buildResponseSchema = (responseSchema: any) => {
return {
type: 'object',
properties: responseSchema.swaggerDocument
};
};

export default {
buildResponseSchema,
};`

and now using it in the response decorator and it works as expected (minus the scheme name, but it's minor)
@responses({ 200: SwaggerResponseUtil.buildResponseSchema(UserInfo), 500: newVar })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant