Using NJsonSchema.CodeGeneration, I'm able to output the properties as-defined in JSON schema. However, I noticed that in the generated, code, a couple of things are going on:
all of the properties have the
Required = Newtonsoft...DisallowNull
property defined.each property is set to a new instance of a class.
Example:
[Newtonsoft.Json.JsonProperty("myProperty", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public MyProperty MyProperty { get; set; } = new MyProperty();
Question:
How do I make it so that the generated code allows nulls? These are not required properties in the JSON schema, and it doesn't make sense to initialize them. On the other hand, it is handy to have the collection classes initialized by default, so they can be iterated without throwing an exception (this is the current behavior for collections as well).