previously in Django 1.11, I'ved defined Django REST API in this way:
in url.py
url(r'^api/test_token$', api.test_token, name='test_token'), in api.py
@api_view(['POST']) def test_token(request): # ----- YAML below for Swagger ----- """ description: test_token parameters: - name: token type: string required: true location: form """ token = request.POST['token'] return Response("test_token success", status=status.HTTP_200_OK) Now that I am migrating to Django 3.1.5, I'd like to know how the above can be achieved in the same way with Django Rest Framework (DRF). In the above particular case, it is POST API "test_token" that takes in one parameter. And generate API documentation like swagger/redoc (that can be used for testing the API)
How can I implement this on Django 3.x ?
https://stackoverflow.com/questions/65918969/django-rest-framework-custom-post-url-endpoints-with-defined-parameter-with-swag January 27, 2021 at 08:14PM
没有评论:
发表评论