Django APIView decorator create Api Doc
Project description
djangoapiviewdoc
根据装饰器生成api文档
# 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”
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
djangoapiviewdoc-1.0.2.tar.gz
(371.7 kB
view details)
File details
Details for the file djangoapiviewdoc-1.0.2.tar.gz
.
File metadata
- Download URL: djangoapiviewdoc-1.0.2.tar.gz
- Upload date:
- Size: 371.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3319b4cc2c53cfe6e1c12f936e1b28da43d4ec5a92b9b04f1fcbc9075466c49 |
|
MD5 | a341a6d9bac90bceecfe112db9c1a5e3 |
|
BLAKE2b-256 | 0097eb09bcc568e02c044791886f90b2b061e1d1076627e7eea7c91930bbac3d |