0006 automatically generates interface documentation

1 Increase interface documentation configuration in the configuration file

REST_FRAMEWORK = {
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema',
}

2 Create a file org-home.py in the Templates directory of APP

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<H1> Organization Home </ h1>
</body>
</html>

3 Create a file OrgHome.py in the views of APP directory

from django.shortcuts import render
from rest_framework import mixins
from rest_framework.viewsets import GenericViewSet


class OrgHomeViewSet(GenericViewSet):
    def list(self, request, *args, **kwargs):
        """
        [Functional Description] used to obtain tissue Home page </br>
        [Steps] from the first step to the last step </br> start operation
        [Return Value] temporarily did not write </br>
        """
        return render(request, 'org-home.html')

4 urls configuration route points APP

from django.urls import path
from Applications.Organization.views import OrgHome

urlpatterns = [
    path('OrgHome/', OrgHome.OrgHomeViewSet.as_view({'get': 'list'})),
]

5 main routing configuration project

from django.contrib import admin
from django.urls import path, include
from rest_framework.documentation import include_docs_urls

DESCRIPTION = """
        Including constant performance with all interface documentation cloud. Includes the following applications:
        1 Authentication: Authentication Service Application
        2 Organization: Organization Application
"""
urlpatterns = [
    path('admin/', admin.site.urls),
    path('Organization/', include('Applications.Organization.urls')),
    path ( 'docs /', include_docs_urls (title = 'interface document', description = DESCRIPTION)),
]

6 Run the project, enter the IP / docs / interface documentation may see the following results

 

Guess you like

Origin www.cnblogs.com/dorian/p/12348368.html