16 lines
468 B
Python
16 lines
468 B
Python
from fastapi.routing import APIRoute
|
|
from starlette import routing
|
|
|
|
|
|
def post_process_router(app) -> None:
|
|
"""
|
|
Simplify operation IDs so that generated API clients have simpler function
|
|
names.
|
|
|
|
Should be called only after all routes have been added.
|
|
"""
|
|
for route in app.routes:
|
|
if isinstance(route, APIRoute):
|
|
if hasattr(route, "operation_id"):
|
|
route.operation_id = route.name # in this case, 'read_items'
|