How to describe parameters in DRF documents

I am using the Django REST Framework v3.6 built-in online documentation django_rest_framework.documentation( not django-rest-swagger ).

Basically, I follow the official documentation and use this in my URLset configuration:

from rest_framework.documentation import include_docs_urls

urlpatterns = [
    url(r"^", include_docs_urls(title="My API")),
    ...
]

Everything seems to work and I have a nice interactive documentation page, but I have ViewSetwith lookup_field = "slug", and one thing about the generated documentation bothers me:

In path options

I want to get some useful information that this description, for example, "a unique, constantly assigned alphanumeric identifier" or something on this list, but can not find any documentation where this data comes from.

, . docstrings , . slug -- here goes the description docstring, - Markdown.

... :

  • ( ) ?
  • ( ) , ?
+6
2

, . .

DRF ( , ), rest_framework.schemas.SchemaGenerator class , . , .

get_path_fields ( , : get_schema β†’ get_links β†’ get_link), , help_text.

, :

class MyResource(models.Model):
    slug = models.CharField(unique=True, help_text=_("unique alphanumeric identifier"))
    ...

!

+4

. , help_text, . , view queryset . , , . , APIView.

+2

Source: https://habr.com/ru/post/1016834/


All Articles