django-swagger

How to document function-based views parameters?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 03:30:43
问题 I'm developing a REST API with Django 1.11 and Django REST Framework 3.7. I installed Django REST Swagger 2.1 to generate the documentation. I'm using a function-based view like this: from rest_framework.decorators import api_view, permission_classes @api_view(['POST']) @permission_classes((permissions.AllowAny,)) def jwt_auth(request, provider, format=None): """ View description here """ pass As you can see, my view is recognized by Swagger and it has the correct description: " View

How to generate list of response messages in Django REST Swagger?

与世无争的帅哥 提交于 2019-12-18 10:19:51
问题 I have upgraded Django REST Framework to 3.5.0 yesterday because I need nice schema generation. I am using Django REST Swagger to document my API but don't know how to list all possible response messages that an API endpoint provides. It seems that there is automatic generation of success message corresponding to the action my endpoint is performing. So POST actions generate 201 response code, without any description. How would I go about adding all the response messages that my endpoint

Django REST Framework + Django REST Swagger + ImageField

旧巷老猫 提交于 2019-12-05 12:51:02
问题 I created a simple Model with an ImageField and I wanna make an api view with django-rest-framework + django-rest-swagger, that is documented and is able to upload the file. Here is what I got: models.py from django.utils import timezone from django.db import models class MyModel(models.Model): source = models.ImageField(upload_to=u'/photos') is_active = models.BooleanField(default=False) created_at = models.DateTimeField(default=timezone.now) def __unicode__(self): return u"photo {0}".format

Django Rest Framework: How to enable swagger docs for function based views

眉间皱痕 提交于 2019-12-04 02:46:57
问题 I went through Django REST Swagger 2.1.2 documentation. When I tried with class based views, it was working fine. But i did not find any reference on how to enable swagger for function based views as shown below: @api_view(['GET', 'POST']) def app_info(request): ... return response Most of my views.py is filled with function based views, just like above. Any help on how to enable the same will greatly appreciated. Thanks! I am using Django: 1.8; Django REST Swagger: 2.1.2; DRF: 3.6.2 回答1: You

Django Rest Framework: How to enable swagger docs for function based views

两盒软妹~` 提交于 2019-12-01 15:45:44
I went through Django REST Swagger 2.1.2 documentation . When I tried with class based views, it was working fine. But i did not find any reference on how to enable swagger for function based views as shown below: @api_view(['GET', 'POST']) def app_info(request): ... return response Most of my views.py is filled with function based views, just like above. Any help on how to enable the same will greatly appreciated. Thanks! I am using Django: 1.8; Django REST Swagger: 2.1.2; DRF: 3.6.2 Igonato You should be able to use @renderer_classes decorator: from rest_framework_swagger import renderers

How to generate list of response messages in Django REST Swagger?

混江龙づ霸主 提交于 2019-11-29 20:42:48
I have upgraded Django REST Framework to 3.5.0 yesterday because I need nice schema generation. I am using Django REST Swagger to document my API but don't know how to list all possible response messages that an API endpoint provides. It seems that there is automatic generation of success message corresponding to the action my endpoint is performing. So POST actions generate 201 response code, without any description. How would I go about adding all the response messages that my endpoint provides and give them some descriptions? I am using djangorestframework==3.5.0 django-rest-swagger==2.0.7