Skip to content

JsonExtensionData needs to be supported by AutoRest #1057

Closed

Description

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
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions