The package idea is simple: let’s create DRF APIs 
<https://www.django-rest-framework.org/> that care about error responses as 
much as they care about successful ones. As developers, It’s easy for us to 
focus on the API implementation for successful responses and forget about 
the pain of dealing with an API that provides different formats for error 
responses or that doesn’t even document its error responses. This is why I 
created drf-standardized-errors 
<https://github.com/ghazi-git/drf-standardized-errors>: it’s an exception 
handler 
<https://www.django-rest-framework.org/api-guide/exceptions/#custom-exception-handling>
 
that makes it easy to return a standard error format that is properly 
documented out of the box.

Features:

   - 
   
   Highly customizable: we’re developers and we each have our own opinion 
   about what’s the best format. So, one important goal was to allow 
   customization of the exception handling process without having to rewrite 
   the whole exception handler.
   - 
   
   Out of the box support for list and nested serializer errors: even if 
   you have that one complicated API endpoint, we’ve got you covered.
   - 
   
   Plays nicely with error monitoring tools (like Sentry, …): unhandled 
   exceptions will still be reported to error monitoring tools while also 
   returning the standard format to API consumers.
   - 
   
   Generate OpenAPI3 schema for error responses using drf-spectacular 
   <https://github.com/tfranzel/drf-spectacular>: No API is complete 
   without proper documentation. This is work in progress (PR1 
   <https://github.com/ghazi-git/drf-standardized-errors/pull/4> and PR2 
   <https://github.com/ghazi-git/drf-standardized-errors/pull/5>). Most of 
   it is done, but I still need to add tests and documentation. Hopefully, 
   that will be done over the next few week(end)s. But, if you want to get a 
   glimpse on the expected result, here’s a screenshot of a test endpoint 
   using swagger UI 
   
<https://user-images.githubusercontent.com/17159441/172224157-c5c59759-a27e-4f39-ad87-82fb9ba7ca3c.png>
   .
   
If you’d like to take the package for a spin, here’s a link to the quickstart 
guide 
<https://drf-standardized-errors.readthedocs.io/en/latest/quickstart.html>. 
If you want to know more about the error response format, it’s documented 
here 
<https://drf-standardized-errors.readthedocs.io/en/latest/error_response.html>. 
If you don’t like that format, always remember that you can change it 
<https://drf-standardized-errors.readthedocs.io/en/latest/customization.html#change-the-format-of-the-error-response>
.

Would be happy to hear what you think and any suggestions for improvements.

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/7f141c6c-3cc5-4649-8593-75ec8686106en%40googlegroups.com.

Reply via email to