Reputation: 3252
I use the drf-yasg library to generate project documentation for the developer front-ends. I can't figure out how to add my data to the fields Parameters and Responses
For example, this class
class VendorsCreateView(APIView):
"""
:param:
data = {
"vendor_name": "TestName",
"country": "Belarus",
"nda": "2020-12-12",
"parent": "",
"contacts": [{"contact_name": "Mrk", "phone": "2373823", "email": "[email protected]"},
{"contact_name": "Uio", "phone": "34567", "email": "[email protected]"}
]
}
:return: swagger name
"""
But I don't exactly get what I want
How do I add these parameters?
Upvotes: 5
Views: 9152
Reputation: 333
Maybe it will help someone who wants extra parameter in GET-request - you should use argument "manual_parameters" in drf-yasg, e.g. field you want to order by to:
order_by = openapi.Parameter('order_by', openapi.IN_QUERY,
description="field you want to order by to",
type=openapi.TYPE_STRING)
@swagger_auto_schema(manual_parameters=[order_by])
def list(self, request, *args, **kwargs):
Upvotes: 9