Fix(template): form data model serialization#430
Merged
dbanty merged 2 commits intoopenapi-generators:support/0.9.xfrom May 24, 2021
Merged
Fix(template): form data model serialization#430dbanty merged 2 commits intoopenapi-generators:support/0.9.xfrom
dbanty merged 2 commits intoopenapi-generators:support/0.9.xfrom
Conversation
…e <Model>.to_dict()` serializer
- to handle internal UNSET values to not serialize them,
`attr.asdict` do not know UNSET type and will serialize them
Codecov Report
@@ Coverage Diff @@
## main #430 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 47 47
Lines 1548 1548
=========================================
Hits 1548 1548 Continue to review full report at Codecov.
|
Collaborator
|
Relates to #372 which I keep neglecting to finish up 😅 |
Collaborator
|
@p1-ra if you're more familiar with form stuff, could you take a look at that other PR and the questions I had about it? Specifically about using JSON in the form. |
dbanty
approved these changes
May 24, 2021
dbanty
pushed a commit
that referenced
this pull request
May 24, 2021
…. Thanks @p1-ra! * templates / endpoint_module / form_data: do not use `attr.asdict`, use <Model>.to_dict()` serializer - to handle internal UNSET values to not serialize them, `attr.asdict` do not know UNSET type and will serialize them * e2e / update golden-record
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR aims to fix form data serialization.
Form data model was serialized using
attr.asdict, which is not aware of the internal typeUNSETand was serializingUNSETreferences.This PR replace the call to
attr.asdictwith<Model>.to_dictmethod, which knows how to properly serializeUNSETvalues.Before:

After:
