Serialize Base objects in MappedObject - #389
Merged
zliang-akamai merged 3 commits intoApr 9, 2024
Merged
Conversation
zliang-akamai
requested review from
jriddle-linode,
lgarber-akamai and
yec-akamai
and removed request for
a team
April 1, 2024 21:33
lgarber-akamai
left a comment
Contributor
There was a problem hiding this comment.
@zliang-akamai This looks great, thanks for fixing this! Could you add a corresponding unit test?
zliang-akamai
force-pushed
the
zhiwei/expand-base-in-mappedobject
branch
from
April 5, 2024 18:30
e36c55b to
4db25dc
Compare
yec-akamai
approved these changes
Apr 9, 2024
yec-akamai
left a comment
Contributor
There was a problem hiding this comment.
Nice work! Works well on my end
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.
📝 Description
Convert nested
Baseobjects in aMappedObjectto dict in thedictproperty ofMappedObject.This can prevent exception of
TypeError: Object of type SomeBaseType is not JSON serializablewhen passing thedictproperty of aMappedObjectinto the json library for serializing.✔️ How to Test
Automated Testing
Manual Testing
Expected Result
Before (dev branch)
After
{ "ipv4": { "public": [ { "address": "172.233.181.52", "gateway": "172.233.181.1", "subnet_mask": "255.255.255.0", "prefix": 24, "type": "ipv4", "public": True, "rdns": "172-233-181-52.ip.linodeusercontent.com", "linode_id": 56675621, "region": "us-mia", "vpc_nat_1_1": None, } ], "private": [], "shared": [], "reserved": [], "vpc": [], }, "ipv6": { "slaac": { "address": "2a01:7e04::f03c:94ff:fe72:158f", "gateway": "fe80::1", "subnet_mask": "ffff:ffff:ffff:ffff::", "prefix": 64, "type": "ipv6", "rdns": None, "linode_id": 56675621, "region": "us-mia", "public": True, }, "link_local": { "address": "fe80::f03c:94ff:fe72:158f", "gateway": "fe80::1", "subnet_mask": "ffff:ffff:ffff:ffff::", "prefix": 64, "type": "ipv6", "rdns": None, "linode_id": 56675621, "region": "us-mia", "public": False, }, "ranges": [], }, }