Browse Source

Skip HEAD in OpenAPI schema generation

HEAD is auto-added for GET routes but should not appear in the
OpenAPI schema — it is implicitly supported per the HTTP spec.
This avoids duplicate operation ID warnings.
pull/15359/head
Thor Agent 3 months ago
parent
commit
6686054d5e
  1. 2
      fastapi/openapi/utils.py

2
fastapi/openapi/utils.py

@ -279,6 +279,8 @@ def get_openapi_path(
route_response_media_type: str | None = current_response_class.media_type
if route.include_in_schema:
for method in route.methods:
if method == "HEAD":
continue # HEAD is auto-added for GET routes, not shown in OpenAPI schema
operation = get_openapi_operation_metadata(
route=route, method=method, operation_ids=operation_ids
)

Loading…
Cancel
Save