django-rest-frameworkdrf-yasg

How to add own Parameters and Response values in the drf-yasg library for swagger documentation?


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": "dRqT@rgmail.com"},
                         {"contact_name": "Uio", "phone": "34567", "email": "rdq@gmail.com"}
                         ]
        }
    :return: swagger name
    """

But I don't exactly get what I want enter image description here

How do I add these parameters?


Solution

  • @swagger_auto_schema decorator is what you are looking for.