4

Is there any lib/parser which can generate API blueprint documentation (apiary) from Django + Django Rest Framework code? Eg:

class UserView(...):
    """
    ## Users list [GET /users]
    + Request (application/json)
        ...
    + Response (application/json)
        ...
    """


class UserSerializer(...):
    """
    ## User (object)
    + id (string)
    + username (string)
    + ...
    """
User
  • 1,978
  • 5
  • 26
  • 47

3 Answers3

4

I use DRF Built-in API documentation,the way to achieve this please refer to the link below.and finally get a website like: enter image description here

You can use markdown syntax(markdown lib is need) to doc viewset like:

class UserViewSet(ModelViewSet):
    """
    create: add user.
    list: list user
    retrieve: retrieve user
    """

doc list_route like :

@list_route(methods=['POST'], permission_classes=[AllowAny], serializer_class=None)
def login(self, request):
    """
     login
     <p>【Receive】tel: tel password: password keep_login: Token change
     <p>【Return】200 success 400 failed
    """

DRF Documenting your API

By the way,now build-in docs's table Description is get form serializer fields's help_text,I change it to label,if you want change it too,tell me and i will post the code related to it again.

Community
  • 1
  • 1
Ykh
  • 7,567
  • 1
  • 22
  • 31
  • Thanks for your reply, but I'm working with different kind of developers, and we are using blueprint api only. – User Mar 09 '18 at 10:46
  • Hi there! I am trying to document my API like this. I am struggling with the description field. How can I add text to it? And is there also a way of customizing the template/schema? – Micromegas Dec 06 '19 at 13:36
1

For generating an API blueprint documentation with Django Rest Framework code, you need to you describe your API using a simple markdown-like syntax. That means that you use Blueprint and aglio package for example. Otherwise, there are also a number of great third-party documentation tools available.

Junior Gantin
  • 2,102
  • 1
  • 18
  • 24
  • 1
    As i thought, only file with markdown syntax. Maybe it's time to start such kind of open source project :-) – User Mar 08 '18 at 21:12
0

You can give a try to swagger

for more info see here: http://www.django-rest-framework.org/topics/documenting-your-api/#third-party-packages

andilabs
  • 22,159
  • 14
  • 114
  • 151