I’m working on a project here which could helps you for generating openapi easily without have to execute or config anything just run your server. Here it is flask-toolkits
the implementation is via your view function and its really flexible. Its inspired by FastAPI’s openapi setup
from typing import Optional
from flask import Flask
from flask_toolkits import AutoSwagger, APIRouter, Body, Header, Query
from flask_toolkits.responses import JSONResponse
app = Flask(__name__)
auto_swagger = AutoSwagger()
app.register_blueprint(auto_swagger)
router = APIRouter("email", __name__, url_prefix="/email")
@router.post("/read", tags=["Email Router"])
def get_email(
token: int = Header(),
id: int = Body(),
name: Optional[str] = Body(None),
race: Optional[str] = Query(None)
):
return JSONResponse({"id":id, "name": name})
app.register_blueprint(email_router)
if __name__ == "__main__":
app.run()
go to localhost:5000/docs
and here you go
Read more here: Source link