Monday, 30 December 2019

Defining different schema for both get and post request - AutoSchema Django Rest Framework

I am trying to define AutoSchema (to be shown in django rest framework swagger) for my REST API in Django REST framework. There's this class that extends APIView.

The class has both 'get' and 'post' methods. Like:

class Profile(APIView):
permission_classes = (permissions.AllowAny,)
schema = AutoSchema(
    manual_fields=[
        coreapi.Field("username",
                      required=True,
                      location='query',
                      description='Username of the user'),

    ]
)
def get(self, request):
    return
schema = AutoSchema(
    manual_fields=[
        coreapi.Field("username",
                      required=True,
                      location='form',
                      description='Username of the user '),
        coreapi.Field("bio",
                      required=True,
                      location='form',
                      description='Bio of the user'),

    ]
)
def post(self, request):
    return

The problem is I want different schema for both get and post request. How can I achieve this using AutoSchema?



from Defining different schema for both get and post request - AutoSchema Django Rest Framework

No comments:

Post a Comment