-
-
Notifications
You must be signed in to change notification settings - Fork 229
Add additional property support by subscripting model #252
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
Merged
dbanty
merged 21 commits into
openapi-generators:main
from
benchling:additionalProperties-support
Dec 8, 2020
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
a96621d
Add additional property support by subscripting model
packyg f8ca735
Update e2e golden records
packyg 62fad1e
Add models with additionalProperties to golden record
packyg f6028d3
PR Feedback: Set additional properties directly
packyg 4c0fbd0
PR Feedback: Just make additionalProperties public
packyg b13d282
Handle edge cases of additionalProperties to interpret per the spec
packyg 7b72c9a
Update golden record's spec to specify no additional props on existin…
packyg 3a827f1
Support modeled additionalProperties
packyg 78015fc
Typing fixes for model properties
packyg e3e0fb4
Add ModelWithPrimitiveAdditionalProperties to e2e test spec
packyg 45ce82b
Regen golden records
packyg b2285cd
Merge branch 'main' into additionalProperties-support
packyg 0d175c0
Update templates to not attempt to pop the same attr multiple times
packyg 1f38a05
Update golden record
packyg da0bc8e
Typing fixes for additional_properties when building model prop
packyg 827d367
Remove unused import from model_property
packyg daf9628
Update existing tests to account for additional_properties
packyg 036f372
Parametrize test_build_model_property to test various additional_prop…
packyg e1ef9a7
Rename AdditionalProperties models to AdditionalProperty as each one …
packyg 0cbe2de
Add test for bad additionalProperties schema
packyg 6ccdde4
uncomment part of test
packyg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,16 @@ | |
{% if property.required %} | ||
{{ property.python_name }} = {{ property.reference.class_name }}.from_dict({{ source }}) | ||
{% else %} | ||
{% if initial_value != None %} | ||
{{ property.python_name }} = {{ initial_value }} | ||
if {{ source }} is not None: | ||
{{ property.python_name }} = {{ property.reference.class_name }}.from_dict(cast(Dict[str, Any], {{ source }})) | ||
{% elif property.nullable %} | ||
{{ property.python_name }} = None | ||
{% else %} | ||
{{ property.python_name }} = UNSET | ||
{% endif %} | ||
_{{ property.python_name }} = {{source}} | ||
if _{{ property.python_name }} is not None and not isinstance({{ property.python_name }}, Unset): | ||
{{ property.python_name }} = {{ property.reference.class_name }}.from_dict(cast(Dict[str, Any], _{{ property.python_name }})) | ||
{% endif %} | ||
{% endmacro %} | ||
|
||
|
@@ -16,7 +23,7 @@ if {{ source }} is not None: | |
{{ destination }} = {{ source }}.to_dict() | ||
{% endif %} | ||
{% else %} | ||
{{ destination }}{% if declare_type %}: {{ property.get_type_string() }}{% endif %} = UNSET | ||
{{ destination }}{% if declare_type %}: Union[{% if property.nullable %}None, {% endif %}Unset, Dict[str, Any]]{% endif %} = UNSET | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here - the type was wrong here |
||
if not isinstance({{ source }}, Unset): | ||
{% if property.nullable %} | ||
{{ destination }} = {{ source }}.to_dict() if {{ source }} else None | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
This addresses what I think was a bug before
(Below has to do with the fact we are now
pop
ing the dict values)