Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

374
Views
How can I create Swagger docs for dynamic Flask endpoints?

I have a list of endpoints like below.

endpoints ["/endpoint1", "/endpoint2", "/endpoint3"]

I would like to create dynamic endpoints in my app and create swagger API docs for all the endpoints, how can I do this.

@app.route(<endpoint>):
  def process():
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Use Enum--(FastAPI doc) classes

from enum import Enum
from fastapi import FastAPI


class 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,

enter image description here

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!