Skip to content

Commit

Permalink
Manually remove webhook_events_filter title from OpenAPI schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mattt committed Sep 16, 2024
1 parent 5e81238 commit c681a21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion python/cog/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class PredictionRequest(PredictionBaseModel):
webhook: Optional[WebhookUrl] = None
webhook_events_filter: Optional[List[WebhookEvent]] = pydantic.Field(
default=WebhookEvent.default_events(),
title=None,
)

@classmethod
Expand Down
12 changes: 12 additions & 0 deletions python/cog/server/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,24 @@ def unwrap_pydantic_serialization_iterators(obj: Any) -> Any:
def update_openapi_schema_for_pydantic_2(
openapi_schema: Dict[str, Any],
) -> None:
_remove_webhook_events_filter_title(openapi_schema)
_remove_empty_or_nullable_anyof(openapi_schema)
_flatten_selected_allof_refs(openapi_schema)
_extract_enum_properties(openapi_schema)
_set_default_enumeration_description(openapi_schema)


def _remove_webhook_events_filter_title(
openapi_schema: Dict[str, Any],
) -> None:
try:
del openapi_schema["components"]["schemas"]["PredictionRequest"]["properties"][
"webhook_events_filter"
]["title"]
except KeyError:
pass


def _remove_empty_or_nullable_anyof(
openapi_schema: Union[Dict[str, Any], List[Dict[str, Any]]],
) -> None:
Expand Down

0 comments on commit c681a21

Please sign in to comment.