How to sort methods by method type in FastAPI Swagger API?

Viewed 198

How can I set a sort order for the API methods in the FastAPI Swagger autodocs? I would like all my methods grouped by type (GET, POST, PUT, DELETE).

This answer shows how to do it in Java. How can I do it in Python?

from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def list_all_components():
    pass

@app.get("/{component_id}")
def get_component(component_id: int):
    pass

@app.post("/")
def create_component():
    pass

@app.put("/{component_id}")
def update_component(component_id: int):
    pass

@app.delete("/{component_id}")
def delete_component(component_id: int):
    pass

enter image description here

1 Answers
Related