Use django rest framework and django-rest-swagger in documentation of the methods it is not showing available GET parameters and the question is how can I set?
code:
# views.py
@api_view(['GET'])
def tests_api(request):
"""
:param request:
:return:
"""
id = request.query_params.get('id')
name = request.query_params.get('name')
return Response({'user': name, 'text': 'Hello world'})
# urls.py
urlpatterns = [
url(r"^api/v1/tests_api/$", tests_api),
]
http api:
GET https://127.0.0.1/api/v1/tests_api/?name=Denis&id=3
HTTP/1.1 200 OK
...
{
"user": "Denis",
"text": "Hello world"
}
now:
example:
Russian version.
Declare schema manually and specify fields there with location query
schema = ManualSchema(fields=[
coreapi.Field(
"name",
required=True,
location="query",
schema=coreschema.String()
),
]
)
See doc for details
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With