I made an API and want to make swagger doc. I don't develop any Serializes for that.
Views.py
class DeliveryView(APIView):
renderer_classes = (XMLRenderer,)
def get_campaign_vast(self, request, *args):
return response
def get(self, request):
return self.get_campaign_vast(request, data)
def post(self, request):
"""
This text is the description for this API
---
param1 -- A first parameter
param2 -- A second parameter
"""
data = request.data
return self.get_campaign_vast(request, data)
urls.py
from django.conf.urls import url,include
from django.contrib import admin
from rest_framework_swagger.views import get_swagger_view
schema_view = get_swagger_view(title='Add Delivery')
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$',schema_view),
url(r'^', include('deliverymanagment.urls')),
]
I want to get all the parameters in Swagger which i am not getting.
i am not able to get parameters
i am using:
django-rest-swagger==2.1.1
djangorestframework==3.5.3
Consider using the
GenericAPIView
instead as this will generate the documentation. It is a bit of a hack using this when the endpoint does not relate to a model, but it does work.As an example, the following code will create an endpoint that only accepts post requests and is documented within swagger using the seralizer.
The
get_swagger_view()
method does not give you the control to add parameters and descriptions to the urls in your appThe solution for this is to use explicit schema definition. You can create a Document which is a representation of the Core API schema container. Go through the following link. Read the Core API section
Core API schema generator
This will require you to create a schema for the urls and the parameters that are used in your Application.
Create a file for swagger
For explanation on
coreapi.Document
,coreapi.Field
,coreapi.Link
kindly refer to the above mentioned link.Create the url for the swagger docs: