-
I have JSON along these lines;
I'm getting this error;
Below is the attempt at my encoding. The JSON itself is minimised from from an external service, that I hope hoping to call via a smithy client...
Based on my reading of this docs, this is a faithful encoding... but have I missed something? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
@Quafadas you have the
{
"Network": {
"id" : "sdfgh",
"network": {
"nodes": [
{
"id": "ed228e09-d0bd-4f5a-a0c1-0eed3a8a783b",
"name": "",
"payload": {
"type": "Exposure",
"ExposureSegments": null
}
},
{
"id": "93d00412-4db0-4606-ab72-8314f75816a9",
"name": "Xl",
"payload": {
"type": "Section",
"InceptionDate": "2019-01-01",
"ExpiryDate": "2019-12-31",
"Layers": [
{
"occType": "Ded",
"share": 1.0
}
]
}
}
]
}
}
} |
Beta Was this translation helpful? Give feedback.
-
I'm also sorry to inform you that, in the current version of smithy4s, you'll have to duplicate some information in various structures :
On the brightside, we're working hard to make Smithy4s understand Smithy 2.0 which was released last Wednesday. Smithy 2.0 adds the concept of "mixins" which will allow for saving a lot of duplication. We're hoping to get a release out in the weeks to come. |
Beta Was this translation helpful? Give feedback.
@Quafadas you have the
@discriminated
trait at the wrong level, or thetype
field in the json at the wrong level, depending on how you see things.type
field you've added in theCfnDigraphNode
shape in your smithy model. Thetype
field in the json level is taken care of implicitly by smithy4s via thediscriminated
trait, without polluting the models. Smithy4s actually protects against the manual addition of the discriminator field, this is because giving the user access to the field would mean putting them at risk of creating invalid instances.@discriminated("type")
trait, as you've placed it, indicates that the json objects underpayload
s…