Skip to content

Commit

Permalink
catch common resource schema issues in cfn validate
Browse files Browse the repository at this point in the history
similar to #414
  • Loading branch information
PatMyron authored Apr 13, 2021
1 parent a143ded commit 3036779
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/rpdk/core/data_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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():
Expand Down Expand Up @@ -190,22 +192,25 @@ def load_resource_spec(resource_spec_file): # pylint: disable=R # noqa: C901
{
"minProperties",
"maxProperties",
"additionalProperties",
},
),
(
{"array"},
{
"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,
)
Expand Down

0 comments on commit 3036779

Please sign in to comment.