chore: add deprecated to combined schema

The _filter_combined_schema function was excluding deprecated
operations. I updated it to include all operations (deprecated and
non-deprecated) for the combined/stainless spec, so these deprecated
endpoints are now included.

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han 2025-11-12 14:48:34 +01:00
parent 73861b504d
commit 500804f0eb
No known key found for this signature in database
3 changed files with 70 additions and 9 deletions

View file

@ -1637,21 +1637,21 @@ def _filter_deprecated_schema(openapi_schema: dict[str, Any]) -> dict[str, Any]:
def _filter_combined_schema(openapi_schema: dict[str, Any]) -> dict[str, Any]:
"""
Filter OpenAPI schema to include both stable (v1) and experimental (v1alpha, v1beta) APIs.
Excludes deprecated endpoints. This is used for the combined "stainless" spec.
Includes deprecated endpoints. This is used for the combined "stainless" spec.
"""
filtered_schema = openapi_schema.copy()
if "paths" not in filtered_schema:
return filtered_schema
# Filter paths to include stable (v1) and experimental (v1alpha, v1beta), excluding deprecated
# Filter paths to include stable (v1) and experimental (v1alpha, v1beta), including deprecated
filtered_paths = {}
for path, path_item in filtered_schema["paths"].items():
if not isinstance(path_item, dict):
continue
# Filter at operation level, not path level
# This allows paths with both deprecated and non-deprecated operations
# Include all operations (both deprecated and non-deprecated) for the combined spec
# Filter at operation level to preserve the structure
filtered_path_item = {}
for method in ["get", "post", "put", "delete", "patch", "head", "options"]:
if method not in path_item:
@ -1660,13 +1660,10 @@ def _filter_combined_schema(openapi_schema: dict[str, Any]) -> dict[str, Any]:
if not isinstance(operation, dict):
continue
# Skip deprecated operations
if operation.get("deprecated", False):
continue
# Include all operations, including deprecated ones
filtered_path_item[method] = operation
# Only include path if it has at least one operation after filtering
# Only include path if it has at least one operation
if filtered_path_item:
# Check if path matches version filter (stable or experimental)
if _is_stable_path(path) or _is_experimental_path(path):