python – Disable openapi-generator from overriding the controllers implementation to default

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()

router = APIRouter("email", __name__, url_prefix="/email")"/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})


if __name__ == "__main__":

go to localhost:5000/docs

and here you go

enter image description here

Read more here: Source link