From 70b6979c8a9e5bd89b3a3cb296b1580b5e9cf5f4 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Mon, 28 Nov 2022 18:57:12 +0100 Subject: [PATCH] Add validation for additional properties [noissue] --- pulpcore/cli/common/openapi.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pulpcore/cli/common/openapi.py b/pulpcore/cli/common/openapi.py index 4cd884a13..c88dcbe1d 100644 --- a/pulpcore/cli/common/openapi.py +++ b/pulpcore/cli/common/openapi.py @@ -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(