Generate RESTful API and OpenAPI document for your Flask project.
Project description
flask-openapi3
Generate RESTful API and OpenAPI document for your Flask project.
Installation
$ pip install -U flask-openapi3
A Simple Example
Here's a simple example, further go to the wiki
from pydantic import BaseModel
from flask_openapi3 import OpenAPI
from flask_openapi3.models import Info, Tag
info = Info(title='book API', version='1.0.0')
app = OpenAPI(__name__, info=info)
book_tag = Tag(name='book', description='图书')
class BookData(BaseModel):
age: int
author: str
@app.get('/book', tags=[book_tag])
def get_book(query: BookData):
"""get books
get all books
"""
return {
"code": 0,
"message": "ok",
"data": [
{"bid": 1, "age": query.age, "author": query.author},
{"bid": 2, "age": query.age, "author": query.author}
]
}
if __name__ == '__main__':
app.run(debug=True)
API docs
Run the simple example, and go to http://127.0.0.1:5000/openapi.
You will see the document: Swagger UI and Redoc.
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
flask-openapi3-0.9.0.tar.gz
(841.9 kB
view hashes)
Built Distribution
flask_openapi3-0.9.0-py3-none-any.whl
(847.4 kB
view hashes)
Close
Hashes for flask_openapi3-0.9.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c966d275aba721bfe04f15b55f71a50726ac8806fb6f5f2a847bab92cbcb90f |
|
MD5 | b042040eaae0ac2c6cd6dfffc87cc5d6 |
|
BLAKE2b-256 | 2c607e077bbd5b2179e46c3cabb61024f4406677f33b5e311adead6248fe98b9 |