I am migrating my Django 1.11.7 to 2.x. One of the problems is django-rest-swagger, it is now deprecated. And drf-yasg should now be the way for the API documentation and creation. I need to do it in a similar way of creating custom api as so it doesnt break anything in the mobile.
Previously, it looks like this (django-rest-swagger==2.1.1)
here is the old code snippet that works nicely in Django 1.11.7 and django-rest-swagger==2.1.1:
using swagger_schema.py
https://gist.github.com/axilaris/2f72fef8f30c56d5befe9e31cd76eb50
in url.py:
from rest_framework_swagger.views import get_swagger_view
from myapp.swagger_schema import SwaggerSchemaView
urlpatterns = [
url(r'^swaggerdoc/', SwaggerSchemaView.as_view()),
url(r'^api/v1/general/get_countries$', api.get_countries, name='get_countries'),
in api.py:
@api_view(['POST'])
def get_countries(request):
# ----- YAML below for Swagger -----
"""
description: countries list
parameters:
- name: token
type: string
required: true
location: form
"""
......
return Response(countries_list, status=status.HTTP_200_OK)
My question is how to do it in drf-yasg similarly, as I want to migrate this code and dont break anything on the mobile.
probably try to do this on this latest stable releases:
djangorestframework==3.9
drf-yasg==1.16.1