Search code examples
django-rest-frameworkdrf-yasg

drf-yasg document input and output serializer for GET request


I'd like to document input schemas and output schemas for GET request with drf-yasg.

It doesn't seem to be easy.

     @swagger_auto_schema(
         manual_parameters=[
             openapi.Parameter('cart_id', in_=openapi.IN_QUERY,
                               type=openapi.TYPE_INTEGER)
         ])

The above code shows the GET parameter, but somehow hides the response schema.

@swagger_auto_schema(methods=['put', 'post'], request_body=UserSerializer)

I can't use request_body for GET query parameters, it's only for post body

So How do I document my input schema and output schema with drf-yasg ?


Solution

  • You can use query_serializer

    Found it https://medium.com/@arjunsinghy96/customised-api-documentation-for-django-rest-framework-projects-using-drf-yasg-d6db9ba5cff3

    was hard to get it from the official doc.