Metadata-Version: 2.3
Name: sanic-api
Version: 0.3.0a1
Summary: Sanic 框架实用API工具集，拥有自动生成文档、参数校验、配置的导入、日志功能的优化等功能，更好的助力接口的开发
Project-URL: homepage, https://github.com/x-haose/sanic-api
Project-URL: repository, https://github.com/x-haose/sanic-api
Project-URL: documentation, https://github.com/x-haose/sanic-api
Author-email: 昊色居士 <xhrtxh@gmail.com>
License: MIT
Keywords: Sanic,Sanic扩展,异步
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: BSD
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: hs-config==0.1.3a5
Requires-Dist: loguru>=0.7.2
Requires-Dist: loki-logger-handler>=0.1.4
Requires-Dist: orjson>=3.8.6
Requires-Dist: pydantic-settings[toml,yaml]>=2.5.2
Requires-Dist: pydantic[dotenv]>=2.9.2
Requires-Dist: requests>=2.32.3
Requires-Dist: sanic-ext>=23.12.0
Requires-Dist: sanic>=23.12.0
Requires-Dist: sentry-sdk>=2.17.0
Requires-Dist: ujson>=5.7.0
Description-Content-Type: text/markdown

![logo](https://images.haose.pro/2022/12/19/logo_17%3A34%3A07_qkt9yi4d7u.png)

[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)
[![Python](https://img.shields.io/badge/Python-3.8+-yellow.svg?logo=python)]()
[![Sanic](https://img.shields.io/badge/framework-Sanic-Server.svg)](http://www.gnu.org/licenses/agpl-3.0)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

# Sanic-API

让您的sanic服务程序更好的支持API文档、参数校验、日志打印、响应规范等

## 特性

- 无需任何多余改动，全自动生成openapi文档，使用更加方便

- 基于`pydantic`的参数校验器，让接口的请求及响应更符合你的预期

- 使用`loguru`库代替官方`logging`日志库，并对访问日志进行扩展，支持打印接口耗时、接口参数

- 使用`{code: 0, data: null, msg: ""}`样式的接口返回

- 对接口中的异常进行拦截，及自定义错误码

- 接口返回样式可自定义配置

## 截图

## 路线图

- 增加一键生成预设项目cli命令

- 编写详细文档

- API接口增加请求头、URL路径参数收集和校验:

## 安装

使用 pip 安装 sanic-api

```bash
  pip install sanic-api
```

## 使用方法/示例

```python
from sanic import Sanic, text
from sanic_api import init_api

app = Sanic("Sanic-API")


@app.get('/')
async def index(request):
    return text("Sanic-API Example")


def main():
    init_api(app)
    app.run(access_log=True)


if __name__ == '__main__':
    main()

```

## 开发

要部署这个项目，请运行

```bash
  pip install pdm
  pdm sync
```

## 文档

[文档](https://linktodocumentation)
