I would like to add Swagger to a Django rest framework, but I can't get POST body parameters...
What I do:
serrings.py
INSTALLED_APPS = [
....
'rest_framework_swagger',
]
REST_FRAMEWORK = {
'DEFAULT_PARSER_CLASSES': [
'rest_framework.parsers.FormParser',
'rest_framework.parsers.MultiPartParser',
'rest_framework.parsers.JSONParser',
]
}
urls.py
schema_view = get_swagger_view(title='My API')
urlpatterns = [
path('', schema_view),
...
]
Views.py
class MyView(APIView):
def post(self, request, format=None):
...
return Response(something)
But my swagger always looks like :
In this case I can't post my body parameter (json) to try it out... How to fix this
swagger picks the fields name from serializer class, so you have to add the serializer class name in view.