-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for docs generation when no items key for a schema property of array type is present. #1052
Fix for docs generation when no items key for a schema property of array type is present. #1052
Conversation
@@ -959,6 +959,22 @@ def __set_property_type(prop_type, single_type=True): | |||
lambda markdown_value: f"List of {markdown_value}" | |||
) # noqa: E731 | |||
|
|||
if "items" not in prop.keys(): | |||
LOG.warning( | |||
'Warning: found schema property of array type with no "items" key; \n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the best default?
"items": {
"type": "string"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not the default value here, it is just an example in the event the (hook's) author chooses to have an input property of array
type, whereas its items are of the string
desired type.
Do you mind posting what the docs look like after this change? |
@brianlaoaws sure - here is an example output whereas in the schema there were no
|
Issue #, if available:
Description of changes:
Fix for documentation generation when no
items
key for a schema property ofarray
type is present. When runningcfn generate
, for example against a schema of a CloudFormation hook that is missing theitems
node for a given property ofarray
type, while the schema validation succeeds, the document generation logic fails with aKeyError
because it assumes theitems
node is present in the input data:This change fixes this behavior by leaving the schema validation unchanged, and by defaulting to an empty map for
items
ifitems
itself is not present in the input data. Proposed changes also include a warning message for the user to take action if needed.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.