The current structure for additional properties on objects is difficult for consumers to use. They must deal with type casting and the specific dynamic implementations of each serialization library (JElement or JsonElement, etc). For cases where the object is ONLY made up of additional properties, without any explicitly defined properties, this can be made much simpler by representing it is as dictionary with string keys. In particular, if a schema is defined for the values of the additional properties this can be directly represented as a strong type on the dictionary value.
Modifications
Use a Dictionary<string, T> whenever an object with no properties or inheritence allows additional properties
Improve the JsonSerializerContext property naming hints to handle generics and nullables cleanly
Ensure that we add JsonElement and JsonObject to the JsonSerializerContext if required
Results
Simple dictionaries are much easier to consume and fewer nested model types are produced unnecessarily
This does create a breaking change for generated SDKs moving from 0.4 to 0.5 of Yardarm
If an OpenAPI schema includes an object with only additional properties and later an explicit property is added it will produce a breaking change in generated SDKs. However, this seems like a rare corner case and the value of supporting simple dictionaries seems to outweigh this concern.
Motivation
The current structure for additional properties on objects is difficult for consumers to use. They must deal with type casting and the specific dynamic implementations of each serialization library (JElement or JsonElement, etc). For cases where the object is ONLY made up of additional properties, without any explicitly defined properties, this can be made much simpler by representing it is as dictionary with string keys. In particular, if a schema is defined for the values of the additional properties this can be directly represented as a strong type on the dictionary value.
Modifications
Results
Resolves #203