Skip to content

Commit

Permalink
Add validation for additional properties
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
mdellweg committed Nov 29, 2022
1 parent b77899d commit 70b6979
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pulpcore/cli/common/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,12 @@ def validate_object(self, schema: Any, name: str, value: Any) -> Dict[str, Any]:
raise OpenAPIValidationError(
_("'{name}' is expected to be an object.").format(name=name)
)
properties = schema.get("properties")
if properties is not None:
properties = schema.get("properties", {})
additional_properties = schema.get("additionalProperties")
if properties or additional_properties is not None:
value = value.copy()
for property_name, property_value in value.items():
property_schema = properties.get(property_name)
property_schema = properties.get(property_name, additional_properties)
if not property_schema:
raise OpenAPIValidationError(
_("Unexpected property '{property_name}' for '{name}' provided.").format(
Expand Down

0 comments on commit 70b6979

Please sign in to comment.