How can I create Swagger docs for dynamic Flask endpoints?
Use Enum
--(FastAPI doc) classes
from enum import Enumfrom fastapi import FastAPIclass ModelName(str, Enum): endpoint1 = "endpoint1" endpoint2 = "endpoint2" endpoint3 = "endpoint3"app = FastAPI()@app.get("/model/{model_name}")async def process(model_name: ModelName): return {"model_name": model_name, "message": "Some message"}
and thus you will get the result as follows,