I am trying to do Django REST function based API with swagger following these instructions.
https://github.com/m-haziq/django-rest-swagger-docs
However, I am unable to get any parameters shown in the function. This is the screenshot of swagger NOT displaying any parameters. https://imgur.com/a/fDITT https://imgur.com/a/n5CDU
UPDATE:This is how I want to achieve with the parameters https://imgur.com/a/cLYNF
Here is my API code, I want to have "name" parameters shown in swagger https://gitlab.com/firdausmah/railercom/blob/master/railercomapp/api.py
@api_view(['POST'])
def test_post(request):
# ----- YAML below for Swagger -----
"""
description: This API deletes/uninstalls a device.
parameters:
- name: name
type: string
required: true
location: form
"""
name = request.POST.get('name')
return Response("Data Saved!", status=status.HTTP_201_CREATED)
This is the difference on my pip freeze library with the working example of django-rest-swagger-docs https://gist.github.com/anonymous/c5c328b9e4a6ff3f86676fe930440dd2
What is the problem, you can view the whole source code in gitlab. Thanks.
I found this in readme
*Input parameters for function based views do not appear:* You might be using
incompatible versions, try using `djangorestframework==3.5.3` and `django-rest-swagger==2.1.1`.
I updated to djangorestframework==3.5.3 and it works
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.