You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug:
The serialization of models using the toArray and toJSON functions is including null properties instead of excluding them from the JSON string. These additional fields will cause an error when trying to instantiate the model with the saved JSON string.
Expected behavior:
I understand that using the object's properties is not the best approach. It is necessary to use only the information contained in the RawModelDataInput field, where the object's state is stored.
Schema:
"juros": {
"$id": "#juros",
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": ["integer", "string"],
"description": "ID ou Sigla do tipo de indicador utilizado."
},
"dataInicioJuros": {
"type": "string",
"format": "datetime"
"description": "Data de início de fluência dos juros."
},
"dataFinalJuros": {
"type": "string",
"format": "datetime"
"description": "Data de término de fluência dos juros."
},
"jurosProRata": {
"type": "boolean",
"description": "Indica que o cálculo de juros considerará frações de períodos"
},
"jurosCompostos": {
"type": "boolean",
"description": "Indica que o cálculo de juros será da modalidade de juros compostos"
}
}
},
Version:
0.23.0
Additional context:
Considering the schema, I would like to create a model with the JSON string {"id": "JUROS_0"} and serialize it to the same output. However, the class will generate the following output JSON string: {"id": "JUROS_0", "dataInicioJuros": null, "dataFimJuros": null, "jurosProRata": null, "jurosCompostos": null}.
The text was updated successfully, but these errors were encountered:
wol-soft
pushed a commit
to wol-soft/php-json-schema-model-generator-production
that referenced
this issue
Jun 7, 2023
Thanks for the report! Now properties which are optional and weren't provided in the initial data will be skipped in the serialization to generate a compatible serialized representation.
The properties will be included if they provide a default value or if the implicitNull option is enabled (compare e560d20#diff-cf7ae3135655cadc9420935644f596f479b07240ac019d479b872fc886b1eeb1)
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug:
The serialization of models using the toArray and toJSON functions is including null properties instead of excluding them from the JSON string. These additional fields will cause an error when trying to instantiate the model with the saved JSON string.
Expected behavior:
I understand that using the object's properties is not the best approach. It is necessary to use only the information contained in the RawModelDataInput field, where the object's state is stored.
Schema:
Version:
0.23.0
Additional context:
Considering the schema, I would like to create a model with the JSON string {"id": "JUROS_0"} and serialize it to the same output. However, the class will generate the following output JSON string: {"id": "JUROS_0", "dataInicioJuros": null, "dataFimJuros": null, "jurosProRata": null, "jurosCompostos": null}.
The text was updated successfully, but these errors were encountered: