Files
2025-03-28 10:08:32 +08:00

17 lines
426 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from fastapi import FastAPI
from fastapi.routing import APIRoute
def simplify_operation_ids(app: FastAPI) -> None:
"""
简化操作 ID以便生成的客户端具有更简单的 API 函数名称
:param app: FastAPI 应用实例
:return:
"""
for route in app.routes:
if isinstance(route, APIRoute):
route.operation_id = route.name