Browse Source

provide a default name for an endpoint without __name__ attribute

pull/15091/head
svlandeg 4 months ago
parent
commit
b2798dab90
  1. 6
      fastapi/openapi/utils.py

6
fastapi/openapi/utils.py

@ -245,10 +245,8 @@ def get_openapi_operation_metadata(
operation["description"] = route.description
operation_id = route.operation_id or route.unique_id
if operation_id in operation_ids:
message = (
f"Duplicate Operation ID {operation_id} for function "
+ f"{route.endpoint.__name__}" # ty: ignore[unresolved-attribute]
)
endpoint_name = getattr(route.endpoint, "__name__", "<unnamed_endpoint>")
message = f"Duplicate Operation ID {operation_id} for function {endpoint_name}"
file_name = getattr(route.endpoint, "__globals__", {}).get("__file__")
if file_name:
message += f" at {file_name}"

Loading…
Cancel
Save