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 UI, 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 UI, Redoc and RapiDoc
-
Data validation: Fast data verification based on Pydantic
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 UI, 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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flask-openapi3-1.1.4.tar.gz.
File metadata
- Download URL: flask-openapi3-1.1.4.tar.gz
- Upload date:
- Size: 939.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
013fb4571d356aa1aaf42572de715d0a73197fb152e32f10f0c9ce7571a30704
|
|
| MD5 |
978a0e7a88846683546c217724ae7f6c
|
|
| BLAKE2b-256 |
bf990c4dd77696df010a6468e63f8aee8fdc70dfd5879346f11184320926d569
|
File details
Details for the file flask_openapi3-1.1.4-py3-none-any.whl.
File metadata
- Download URL: flask_openapi3-1.1.4-py3-none-any.whl
- Upload date:
- Size: 946.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c04af23ad522920eea4ecc8523920d57214118a3ce1053cc975cc25accc04cd
|
|
| MD5 |
6aec571e31039ccbe7c425d75b1760e7
|
|
| BLAKE2b-256 |
b84d083b09436b623ed3df49a1e3892a6e5f6cda2244b0ce7bd324f1634435eb
|