ssaavedra / drf-swagger-extras

Utilities for improving the generation of OpenAPI documentation in a Django REST Framework application.
MIT License
3 stars 0 forks source link

Usage of library is missing #1

Open draskomikic opened 7 years ago

draskomikic commented 7 years ago

Could you please provide example how to use library?

ssaavedra commented 7 years ago

Sorry, I've been out of band for some time, and engaged in other projects.

I have this in my backlog of personal issues, and I'll come back at it.

This started as a personal project, but it makes a lot of sense to put some additonal effort in using it properly. In short, it is a tool for adding more metadata to swagger, such as varying response metadata with models and examples.

You can see an example of usage in the tests folder, like the following:

@responds(500, "On server failure",
          schema={
              ('details', 'norequired'): 'string',
              'required-details': {
                  ('key', 'required'): []
              }
          })
@responds(200, "Always", schema={})
class ExampleView(APIView):
    "Example big comment"
    permission_classes = [permissions.IsAuthenticatedOrReadOnly]

    def get(self, request, *args, **kwargs):
        "Example get comment"
        return Response()

    def post(self, request, *args, **kwargs):
        "Example post comment"
return Response()

That is no excuse for proper documentation and improving the README in general, but if you find this interesting, please let me know!