Django简易json api接口封装。
Project description
django-apis
Django简易json api接口框架。使用pydantic
做接口参数验证。
安装
pip install django-apis
配置项
- DJANGO_APIS_BASE_RESPONSE_CLASS: 通用的接口响应模型
- DJANGO_APIS_OPENAPI_SERVERS: Swagger服务器列表
- DJANGO_APIS_OPENAPI_TITLE: Swagger标题
- DJANGO_APIS_OPENAPI_VERSION: Swagger版本号
- DJANGO_APIS_OPENAPI_DESCRIPTION: Swagger描述
使用案例
import pydantic
from django_apis.views import apiview
from django_apis.schemas import OptionalUploadedFile
@apiview()
def ping() -> str:
return "pong"
class EchoPayload(pydantic.BaseMode):
msg: str
@apiview(methods="post")
def echo(payload: EchoPayload) -> str:
return payload.msg
class ApplyForm(pydantic.BaseMode):
name: str
start_date: str
end_date: str
files: List[OptionalUploadedFile]
@apiview(methods="post")
def apply(form: ApplyForm) -> bool:
return True
版本记录
v0.2.0
- 注意:不兼容0.1.x。
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
django-apis-0.2.0.tar.gz
(11.0 kB
view details)
Built Distribution
File details
Details for the file django-apis-0.2.0.tar.gz
.
File metadata
- Download URL: django-apis-0.2.0.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5d9589178184d5829c24e33522f244936f7daab28d5679faf5a80f0a48747d8 |
|
MD5 | 64f73ac4b1ebd369410142a9b20026b9 |
|
BLAKE2b-256 | 5f74c1eaee11464b70bbf9d6fbb8752c0d44c94495d4a58bd4c354cc7de9f2ae |
File details
Details for the file django_apis-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: django_apis-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68e800e7383db8e3a663cc87a43f222457438a81ca4c877357cb220071f940bf |
|
MD5 | 6554cf13e557efd1bb3a99a8cd8a000f |
|
BLAKE2b-256 | ae2c0da59a958a0974190f8f6dee3f9d09d99918ccbd2a1ff30f93a0fc90d4c3 |