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.6+
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 docs
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='Book')
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.5.tar.gz
(835.8 kB
view hashes)
Built Distribution
flask_openapi3-0.9.5-py3-none-any.whl
(841.4 kB
view hashes)
Close
Hashes for flask_openapi3-0.9.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88a0481421946b09f0d7b13033d1e012277a7d1747719693e47f099d1b329541 |
|
MD5 | 2f81d8cdee19976a00f7a91d04d75637 |
|
BLAKE2b-256 | 9bec9fea60114ce01d8eadb90a752abd189e7cbd723af31ac4a5deebea79a7d2 |