https://github.com/mr-fatalyst/fastopenapi
FastOpenAPI is a library for generating and integrating OpenAPI schemas using Pydantic v2 and various frameworks (AioHttp, Falcon, Flask, Quart, Sanic, Starlette, Tornado).
https://github.com/mr-fatalyst/fastopenapi
aiohttp falcon fastopenapi flask json-schema openapi openapi-generator pydantic pydantic-v2 quart redoc sanic starlette swagger swagger-ui tornado validation web
Last synced: 25 days ago
JSON representation
FastOpenAPI is a library for generating and integrating OpenAPI schemas using Pydantic v2 and various frameworks (AioHttp, Falcon, Flask, Quart, Sanic, Starlette, Tornado).
- Host: GitHub
- URL: https://github.com/mr-fatalyst/fastopenapi
- Owner: mr-fatalyst
- License: mit
- Created: 2025-02-23T16:12:09.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2025-04-24T20:43:59.000Z (about 2 months ago)
- Last Synced: 2025-04-24T21:42:52.126Z (about 2 months ago)
- Topics: aiohttp, falcon, fastopenapi, flask, json-schema, openapi, openapi-generator, pydantic, pydantic-v2, quart, redoc, sanic, starlette, swagger, swagger-ui, tornado, validation, web
- Language: Python
- Homepage:
- Size: 1.51 MB
- Stars: 401
- Watchers: 2
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Citation: CITATION.cff
- Security: .github/SECURITY.md
Awesome Lists containing this project
- awesome-starred - mr-fatalyst/fastopenapi - FastOpenAPI is a library for generating and integrating OpenAPI schemas using Pydantic v2 and various frameworks (AioHttp, Falcon, Flask, Quart, Sanic, Starlette, Tornado). (Python)
README
![]()
FastOpenAPI is a library for generating and integrating OpenAPI schemas using Pydantic and various frameworks.
This project was inspired by FastAPI and aims to provide a similar developer-friendly experience.
![]()
![]()
![]()
![]()
![]()
![]()
---
## 📦 Installation
#### Install only FastOpenAPI:
```bash
pip install fastopenapi
```#### Install FastOpenAPI with a specific framework:
```bash
pip install fastopenapi[aiohttp]
```
```bash
pip install fastopenapi[falcon]
```
```bash
pip install fastopenapi[flask]
```
```bash
pip install fastopenapi[quart]
```
```bash
pip install fastopenapi[sanic]
```
```bash
pip install fastopenapi[starlette]
```
```bash
pip install fastopenapi[tornado]
```---
## 🛠️ Quick Start
### Step 1. Create an application
- Create the `main.py` file
- Copy the code from an example
- For some examples uvicorn is required (`pip install uvicorn`)#### Examples:
- 
Click to expand the Falcon Example
```python
from aiohttp import web
from pydantic import BaseModel
from fastopenapi.routers import AioHttpRouter
app = web.Application()
router = AioHttpRouter(app=app)
class HelloResponse(BaseModel):
message: str
@router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
async def hello(name: str):
"""Say hello from aiohttp"""
return HelloResponse(message=f"Hello, {name}! It's aiohttp!")
if __name__ == "__main__":
web.run_app(app, host="127.0.0.1", port=8000)
```
- 
Click to expand the Falcon Example
```python
import falcon.asgi
import uvicorn
from pydantic import BaseModel
from fastopenapi.routers import FalconRouter
app = falcon.asgi.App()
router = FalconRouter(app=app)
class HelloResponse(BaseModel):
message: str
@router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
async def hello(name: str):
"""Say hello from Falcon"""
return HelloResponse(message=f"Hello, {name}! It's Falcon!")
if __name__ == "__main__":
uvicorn.run(app, host="127.0.0.1", port=8000)
```
- 
Click to expand the Flask Example
```python
from flask import Flask
from pydantic import BaseModel
from fastopenapi.routers import FlaskRouter
app = Flask(__name__)
router = FlaskRouter(app=app)
class HelloResponse(BaseModel):
message: str
@router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
def hello(name: str):
"""Say hello from Flask"""
return HelloResponse(message=f"Hello, {name}! It's Flask!")
if __name__ == "__main__":
app.run(port=8000)
```
- 
Click to expand the Quart Example
```python
from pydantic import BaseModel
from quart import Quart
from fastopenapi.routers import QuartRouter
app = Quart(__name__)
router = QuartRouter(app=app)
class HelloResponse(BaseModel):
message: str
@router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
async def hello(name: str):
"""Say hello from Quart"""
return HelloResponse(message=f"Hello, {name}! It's Quart!")
if __name__ == "__main__":
app.run(port=8000)
```
- 
Click to expand the Sanic Example
```python
from pydantic import BaseModel
from sanic import Sanic
from fastopenapi.routers import SanicRouter
app = Sanic("MySanicApp")
router = SanicRouter(app=app)
class HelloResponse(BaseModel):
message: str
@router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
async def hello(name: str):
"""Say hello from Sanic"""
return HelloResponse(message=f"Hello, {name}! It's Sanic!")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
```
- 
Click to expand the Starlette Example
```python
import uvicorn
from pydantic import BaseModel
from starlette.applications import Starlette
from fastopenapi.routers import StarletteRouter
app = Starlette()
router = StarletteRouter(app=app)
class HelloResponse(BaseModel):
message: str
@router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
async def hello(name: str):
"""Say hello from Starlette"""
return HelloResponse(message=f"Hello, {name}! It's Starlette!")
if __name__ == "__main__":
uvicorn.run(app, host="127.0.0.1", port=8000)
```
- 
Click to expand the Tornado Example
```python
import asyncio
from pydantic import BaseModel
from tornado.web import Application
from fastopenapi.routers.tornado import TornadoRouter
app = Application()
router = TornadoRouter(app=app)
class HelloResponse(BaseModel):
message: str
@router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
def hello(name: str):
"""Say hello from Tornado"""
return HelloResponse(message=f"Hello, {name}! It's Tornado!")
async def main():
app.listen(8000)
await asyncio.Event().wait()
if __name__ == "__main__":
asyncio.run(main())
```
### Step 2. Run the server
Launch the application:
```bash
python main.py
```Once launched, the documentation will be available at:
Swagger UI:
```
http://127.0.0.1:8000/docs
```
ReDoc UI:
```
http://127.0.0.1:8000/redoc
```---
## ⚙️ Features
- **Generate OpenAPI schemas** with Pydantic v2.
- **Data validation** using Pydantic models.
- **Supports multiple frameworks:** AIOHTTP, Falcon, Flask, Quart, Sanic, Starlette, Tornado.
- **Proxy routing provides FastAPI-style routing**---
## 📖 Documentation
Explore the [Docs](https://github.com/mr-fatalyst/fastopenapi/blob/master/docs/en/index.md) for an overview of FastOpenAPI, its core components, and usage guidelines. The documentation is continuously updated and improved.
---
## 📂 Advanced Examples
Examples of integration and detailed usage for each framework are available in the [`examples`](https://github.com/mr-fatalyst/fastopenapi/tree/master/examples) directory.
---
## 📊 Quick & Dirty Benchmarks
Fast but not perfect benchmarks. Check the [`benchmarks`](https://github.com/mr-fatalyst/fastopenapi/tree/master/benchmarks) directory for details.
---
## ✅ Development Recommendations
- Use Pydantic models for strict typing and data validation.
- Follow the project structure similar to provided examples for easy scalability.
- Regularly update dependencies and monitor library updates for new features.---
## 🛠️ Contributing
If you have suggestions or find a bug, please open an issue or create a pull request on GitHub.
---
## 📄 **License**
This project is licensed under the terms of the MIT license.