Generate RESTful API and OpenAPI document for your Flask project.
Project description
flask-openapi3
Generate RESTful API and OpenAPI document for your Flask project.
Requirements
Python 3.7+
flask-openapi3 be dependent on the following libraries:
Installation
pip install -U flask-openapi3
A Simple Example
Here's a simple example, further go to the Example.
from pydantic import BaseModel
from flask_openapi3 import Info, Tag
from flask_openapi3 import OpenAPI
info = Info(title='book API', version='1.0.0')
app = OpenAPI(__name__, info=info)
book_tag = Tag(name='book', description='Some Book')
class BookQuery(BaseModel):
age: int
author: str
@app.get('/book', tags=[book_tag])
def get_book(query: BookQuery):
"""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.9.tar.gz
(837.5 kB
view hashes)
Built Distribution
flask_openapi3-0.9.9-py3-none-any.whl
(844.2 kB
view hashes)
Close
Hashes for flask_openapi3-0.9.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8c502c58bb7ff995e1929a05a8809e3fde787f44c4a1c4951d3ea3c6aaf329e |
|
MD5 | 4850f9a0cf5e31f2da1af0f5c7cbced9 |
|
BLAKE2b-256 | 2b0324c65716dfe4cc36d4fde1040fc388be8a1faba062d67ddf6e7801a62dcd |