From 30367798fb8456eac0eb545b156f88b958b63765 Mon Sep 17 00:00:00 2001 From: Pat Myron Date: Tue, 13 Apr 2021 10:02:13 -0700 Subject: [PATCH] catch common resource schema issues in cfn validate similar to https://github.com/aws-cloudformation/cloudformation-cli/issues/414 --- src/rpdk/core/data_loaders.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/rpdk/core/data_loaders.py b/src/rpdk/core/data_loaders.py index d528e736..24a5dac0 100644 --- a/src/rpdk/core/data_loaders.py +++ b/src/rpdk/core/data_loaders.py @@ -145,7 +145,7 @@ def load_resource_spec(resource_spec_file): # pylint: disable=R # noqa: C901 LOG.debug("Resource spec validation failed", exc_info=True) raise SpecValidationError(str(e)) from e - min_max_keywords = { + type_specific_keywords = { "minimum", "maximum", "minLength", @@ -156,6 +156,8 @@ def load_resource_spec(resource_spec_file): # pylint: disable=R # noqa: C901 "maxItems", "exclusiveMinimum", "exclusiveMaximum", + "additionalItems", + "additionalProperties", } try: # pylint: disable=R for _key, schema in JsonSchemaFlattener(resource_spec).flatten_schema().items(): @@ -190,6 +192,7 @@ def load_resource_spec(resource_spec_file): # pylint: disable=R # noqa: C901 { "minProperties", "maxProperties", + "additionalProperties", }, ), ( @@ -197,15 +200,17 @@ def load_resource_spec(resource_spec_file): # pylint: disable=R # noqa: C901 { "minItems", "maxItems", + "additionalItems", }, ), ]: if ( property_type in types - and min_max_keywords - allowed_keywords & property_keywords + and type_specific_keywords - allowed_keywords & property_keywords ): LOG.warning( - "Incorrect min/max JSON schema keywords for type: %s for property: %s", + "Incorrect JSON schema keyword(s) %s for type: %s for property: %s", + type_specific_keywords - allowed_keywords & property_keywords, property_type, property_name, )