-
Notifications
You must be signed in to change notification settings - Fork 83
Add support of oneOf(primitive|object) in the json parser generator #2972
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
Changes from all commits
67dcf0d
978b851
bf22e3c
1585433
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -216,7 +216,12 @@ class ClassJsonElementDeserializerGenerator( | |
| Identifier.PARAM_COLLECTION | ||
| ) | ||
|
|
||
| is TypeDefinition.OneOfClass, | ||
| is TypeDefinition.OneOfClass -> addStatement( | ||
| "%L.add(%T.%L(it))", | ||
| Identifier.PARAM_COLLECTION, | ||
| arrayType.items.asKotlinTypeName(rootTypeName), | ||
| Identifier.FUN_FROM_JSON_ELEMENT | ||
| ) | ||
| is TypeDefinition.Class -> addStatement( | ||
| "%L.add(%T.%L(it.asJsonObject))", | ||
| Identifier.PARAM_COLLECTION, | ||
|
|
@@ -262,12 +267,12 @@ class ClassJsonElementDeserializerGenerator( | |
| rootTypeName: String | ||
| ) { | ||
| val opt = if (nullable) "?" else "" | ||
| beginControlFlow("$assignee = $getter$opt.asJsonObject$opt.let") | ||
|
Contributor
Author
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. This is an important place that I missed. It corresponds to the situation when a When we are deserializing a My new tests only tested the case when I modified an old test here to test this scenario. |
||
| beginControlFlow("$assignee = $getter$opt.let") | ||
|
|
||
| addStatement( | ||
| "%T.%L(it)", | ||
| propertyType.asKotlinTypeName(rootTypeName), | ||
| Identifier.FUN_FROM_JSON_OBJ | ||
| Identifier.FUN_FROM_JSON_ELEMENT | ||
| ) | ||
| endControlFlow() | ||
| } | ||
|
|
||
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.
Now options of
oneOfcan be either a class or a primitive.