Skip to content

Fix deserialization of optional nullable properties #420

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
merged 2 commits into from
May 12, 2021

Conversation

forest-benchling
Copy link
Collaborator

Closes #381.

@codecov
Copy link

codecov bot commented May 9, 2021

Codecov Report

Merging #420 (35e81f9) into main (032a4a4) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #420   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           47        47           
  Lines         1549      1549           
=========================================
  Hits          1549      1549           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 032a4a4...35e81f9. Read the comment docs.

not_required_nullable_model: Union[Unset, None, ModelWithUnionProperty]
if _not_required_nullable_model is None:
not_required_nullable_model = None
elif isinstance(_not_required_nullable_model, Unset):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the case that was not correctly handled before

@forest-benchling
Copy link
Collaborator Author

@dbanty @emann Ready for review. We don't have a more precise way to test the generated models in order to add a regression test, do we?

cc @GitOnUp @dtkav @packyg

Copy link
Collaborator

@dbanty dbanty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! Unfortunately that's as good as we've got for testing templates right now. At some point we probably want to also have unit-like tests which validate the generated code itself (e.g. actually running the code with different values to make sure we get out what was intended). It's somewhere on my list of improvements to make when we make the templates more stable.

@dbanty dbanty merged commit e708750 into openapi-generators:main May 12, 2021
@dbanty dbanty added this to the Next milestone May 12, 2021
p1-ra pushed a commit to P1sec/openapi-python-client that referenced this pull request May 14, 2021
… returned from the API [openapi-generators#420 & openapi-generators#381]. Thanks @forest-benchling!

* Handle optional nullable deserialization

* Fix test
@eli-bl eli-bl deleted the forest-optional-nullable branch November 26, 2024 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optional nullable model properties are deserialized from UNSET to None
2 participants