Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 272
eugene Avatar asked Sep 21 '19 03:09

eugene


Video Answer


1 Answers

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.

like image 109
eugene Avatar answered Oct 19 '22 14:10

eugene