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

Recommend approach to expose generic error handling to the generated OpenAPI specification #1285

Open
mjvkeulen opened this issue Aug 28, 2024 · 0 comments

Comments

@mjvkeulen
Copy link

Django Ninja has default exception handlers for cases like authentication or validation errors. It's lovely how straightforward it is to expand on these for custom use cases.

What is the recommended approach to exposing the format of these generic error responses to the generated OpenAPI specification?

Ideally, this can be done at the root API level or per router. For example in a similar fashion how this can be accomplished using drf-spectacular + drf-standardized-errors when using drf.

A typical example would be that for ValidationErrors the 422 error and the error schema are exposed for any endpoint that uses an input Schema. Adding this manually to each relevant API as @router.post('/some-url', response={201: MyObjectOut, 422: MyCustomValidationError}) feels error prone.

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