routing-controllers-openapi icon indicating copy to clipboard operation
routing-controllers-openapi copied to clipboard

How to handle HTTP errors

Open PhilippMolitor opened this issue 4 years ago • 4 comments

I implemented this library and immediately noticed that there is no example or documentation on how to include routing-controller's HttpErrors in the generated spec. Is there a defined best-practice how to add the spec for a method that is able to throw e.g. a NotFoundError?

PhilippMolitor avatar Jan 26 '21 11:01 PhilippMolitor

No, there isn't. You could use the OpenAPI decorator to add a responses.404 property, or perhaps write another decorator that calls OpenAPI internally to save a bit of typing.

Please share here if you come up with a better solution!

epiphone avatar Jan 26 '21 11:01 epiphone

Is there any plan on supporting that? This seems like a core component to me. Imagine @ErrorResponseSchema(NotFoundError).

PhilippMolitor avatar Jan 26 '21 12:01 PhilippMolitor

No plans, nope. PRs are welcome :+1:

epiphone avatar Jan 26 '21 12:01 epiphone

+1 for this feature

bratanon avatar Feb 26 '21 15:02 bratanon