Closed
Description
openedon May 18, 2016
For the swagger JSON fields that are not well-defined and schema-less, we can add "additionalProperties" field as follow:
"def1": {
"properties": {
"field1": {
"type": "string"
}
},
"additionalProperties": {
"type": "object"
}
}
In C# this should be translated to a property, tagged with [JsonExtensionData] attribute similar to this.
[JsonExtensionData]
public Dictionary<string, object> AdditionalProperties { get; set; }
So if there is a schema-less JSON string in the service response, similar to field2 in the following example (for def1 in the swagger spec above), field2 should be serialized to ‘Dictionary<string, object> AdditionalProperties’ property:
{
"def1": {
"field1": "this is field 1",
"field2": {
"field3": "this is field 3"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels