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

286
Views
¿Cómo agrupar puntos finales de FastAPI en la interfaz de usuario de Swagger?

Comencé a programar usando el marco fastApi y viene con una interfaz swagger incorporada para manejar solicitudes y respuestas. He completado casi 20 apis y es difícil administrar y reconocer apis en la interfaz de swagger. Alguien me dijo que agregara secciones en la interfaz de Swagger para distinguir las API, pero no pude encontrar ningún ejemplo en Google y necesito su ayuda.

Gracias por adelantado...

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede agregar etiquetas a su parámetro de ruta, por ejemplo.

Si tiene algo como esto, usar etiquetas es extremadamente útil.

 @app.delete("/items", tags=["Delete Methods"]) @app.put("/items", tags=["Put Methods"]) @app.post("/items", tags=["Post Methods"]) @app.get("/items", tags=["Get Methods"]) async def handle_items(): return @app.get("/something", tags=["Get Methods"]) async def something(): return

ingrese la descripción de la imagen aquí

Obtendrá esto, también si desea agregar una descripción y no quiere seguir repitiéndose (por ejemplo, agregando la misma descripción en todos los parámetros)

Puedes usar openapi_tags (prefiero esto)

 from fastapi import FastAPI tags_metadata = [ {"name": "Get Methods", "description": "One other way around"}, {"name": "Post Methods", "description": "Keep doing this"}, {"name": "Delete Methods", "description": "KILL 'EM ALL"}, {"name": "Put Methods", "description": "Boring"}, ] app = FastAPI(openapi_tags=tags_metadata) @app.delete("/items", tags=["Delete Methods"]) @app.put("/items", tags=["Put Methods"]) @app.post("/items", tags=["Post Methods"]) @app.get("/items", tags=["Get Methods"]) async def handle_items(): return

Esto le dará el mismo aspecto sin repetición.

ingrese la descripción de la imagen aquí

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!