Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shangsky/flask-sugar
Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints. check parameters and generate API documents automatically. Flask Sugar是一个基于flask,pydantic,类型注解的API框架, 可以检查参数并自动生成API文档
https://github.com/shangsky/flask-sugar
flask openapi python swagger
Last synced: about 1 month ago
JSON representation
Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints. check parameters and generate API documents automatically. Flask Sugar是一个基于flask,pydantic,类型注解的API框架, 可以检查参数并自动生成API文档
- Host: GitHub
- URL: https://github.com/shangsky/flask-sugar
- Owner: ShangSky
- License: mit
- Created: 2021-07-13T06:12:39.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-29T07:45:08.000Z (over 2 years ago)
- Last Synced: 2024-11-14T18:52:39.106Z (about 1 month ago)
- Topics: flask, openapi, python, swagger
- Language: Python
- Homepage: flask-sugar.vercel.app
- Size: 1.72 MB
- Stars: 166
- Watchers: 3
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flask Sugar
- [简体中文](README_zh.md)
Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints.
check parameters and generate API documents automatically
Documentation: or
Source Code:
## Requirements
- Python 3.6+
- Flask 2.0+## Installation
```shell
$ pip install flask-sugar
```## Example
```python
# save this as app.py
from flask_sugar import Sugar, Header
from pydantic import BaseModelapp = Sugar(__name__)
class Item(BaseModel):
name: str
size: intclass Resp(BaseModel):
a: int
b: str
c: str
item: Item```shell
$ flask run --reload
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
```Now visit the API documentation with Swagger UI at http://localhost:5000/doc:
![](https://github.com/ShangSky/flask-sugar/raw/main/docs/img/swagger-ui.png)
visit the API documentation with Redoc at http://localhost:5000/redoc:
![](https://github.com/ShangSky/flask-sugar/blob/main/docs/img/redoc.png)
## License
This project is licensed under the terms of the MIT license.