Generate REST API and OpenAPI documentation for your Flask project.
Project description
Generate REST API and OpenAPI documentation for your Flask project.
Flask OpenAPI3 is a web API framework based on Flask. It uses Pydantic to verify data and automatic generation of interaction documentation: Swagger, ReDoc and RapiDoc.
The key features are:
-
Easy to code: Easy to use and easy to learn
-
Standard document specification: Based on OpenAPI Specification
-
Interactive OpenAPI documentation: Swagger, Redoc and RapiDoc
-
Data validation: Fast data verification based on Pydantic
-
Authorization: Support to reload authorizations in Swagger UI
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 Document
Run the simple example, and go to http://127.0.0.1:5000/openapi.
You will see the documentation: Swagger, Redoc and RapiDoc.
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
Built Distribution
Hashes for flask_openapi3-2.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 484861a0fe379e371b914c236d1db4b7c1cdfac980fc8bfd0b990c4414401461 |
|
MD5 | 96c345f7917bd24c2d324f610f2b8491 |
|
BLAKE2b-256 | b80268b3bd0003c7104879d6accb035220cbc10e61d43d4689a64c5b83fbd579 |