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: accept empty components property in Open Api Definition #2296
fix: accept empty components property in Open Api Definition #2296
Conversation
… property in the Open Api definition body instead of failing, as Components property is an optional property in the OpenApi definition.
components = definition_body.get("components", Py27Dict()) | ||
components = components if components else Py27Dict() |
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.
Isn't second parameter of get
is the default value if the item is None
? If so, the line 1002 would be redundant?
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.
no, get will only return default value if the components
is not the dict at all, but if it is in the dict and its value is None, it will return None and not the default value
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.
Got it, can we add a comment next to it so it won't be removed accidentally in the future.
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.
done
Codecov Report
@@ Coverage Diff @@
## develop #2296 +/- ##
===========================================
+ Coverage 93.58% 94.39% +0.81%
===========================================
Files 90 97 +7
Lines 6124 7087 +963
Branches 1260 1434 +174
===========================================
+ Hits 5731 6690 +959
+ Misses 183 181 -2
- Partials 210 216 +6
Continue to review full report at Codecov.
|
Use a default dict in case if a template contains an empty components property in the Open Api definition body instead of failing, as Components property is an optional property in the OpenApi definition.
Issue #, if available:
Description of changes:
Description of how you validated changes:
Checklist:
make pr
passesExamples?
Please reach out in the comments, if you want to add an example. Examples will be
added to
sam init
through https://github.com/awslabs/aws-sam-cli-app-templates/By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.