Skip to main content

djangoapiviewdoc

根据装饰器生成api文档

版本<=1.1.0

# settings.py
from apiview_doc.decorator import ApiDoc

APIDOC_DECORATOR = ApiDoc()

# views.py
from project_name.settings import APIDOC_DECORATOR
from rest_framework.generics import GenericAPIView


class PersonLoginAPIView(GenericAPIView):
    """
    @author:    JiChao_Song
    @desc:      用户名、密码登录
    @date:      2021/11/29 17:09
    """

    @APIDOC_DECORATOR.start
    @APIDOC_DECORATOR.ApiTag(value = 'user', desc = '用户管理')
    @APIDOC_DECORATOR.ApiOperation(method = 'POST', path = '/user/login', summary = '用户登录')
    @APIDOC_DECORATOR.ApiParams(value = 'username', require = True, type = 'string', desc = '用户名')
    @APIDOC_DECORATOR.ApiParams(value = 'password', require = True, type = 'string', desc = '密码')
    def post(self, request, *args, **kwargs):
        pass


# url.py
from apiview_doc.decorator import api_doc
from views import PersonLoginAPIView


def docs(request):
    context = api_doc()

    return render(request, 'apiview_doc/docs/index.html', context)


urlpatterns = [
    path('login', PersonLoginAPIView.as_view()),
    path('docs', docs),
]

启动项目访问 “/docs”

img.png

版本 >= 1.1.0

# settings.py
from apiview_doc.decorator import ApiDoc
from apiview_doc.openapi import ApiImplicitParam, ApiTag, ApiParameters, ApiOperation, ApiDataType, ApiParamType

# views.py
from rest_framework.generics import GenericAPIView


class PersonLoginAPIView(GenericAPIView):
    """
    @author:    JiChao_Song
    @desc:      用户名、密码登录
    @date:      2021/11/29 17:09
    """

    @ApiTag(name = 'user', description = '用户管理')
    @ApiOperation(method = 'POST', path = 'user/login', summary = '用户登录')
    @ApiParameters(params = [
        ApiImplicitParam(description = '用户名', name = 'username', required = True, paramType = ApiParamType.Body,
                         dataType = ApiDataType.String),
        ApiImplicitParam(description = '密码', name = 'password', required = True, paramType = ApiParamType.Body,
                         dataType = ApiDataType.String),
    ])
    def post(self, request, *args, **kwargs):
        pass


# url.py
from views import PersonLoginAPIView
from apiview_doc.openapi import OpenApi, api_info_list

openapi = OpenApi(
    paths = api_info_list()
)


def get_openapi_docs_url(request):
    context = openapi.__dict__

    return render(request, 'apiview_doc/openapi/index.html', context)

urlpatterns = [
    path('login', PersonLoginAPIView.as_view()),
    path('redocs', get_openapi_docs_url),
]

启动项目访问 “/docs”

img_3.png

Metadata

Release files for djangoapiviewdoc 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djangoapiviewdoc 1.1.3
File Size Uploaded Provenance Actions
djangoapiviewdoc-1.1.3.tar.gz 471.4 kB Without provenance Details for djangoapiviewdoc-1.1.3.tar.gz

Release files / djangoapiviewdoc-1.1.3.tar.gz

Download URL djangoapiviewdoc-1.1.3.tar.gz
Size 471.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3bd8cc057bbc5f46ac7ffaab8b7570e7d56d714a9185bc32e1a7d9b2c730c5a0
BLAKE2b-256 checksum
How to use checksums
00ffbc601b04afa7e1a72c674a3afb9498062598ecc82c66bfa7cf83cc6a407c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Security for djangoapiviewdoc 1.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page