I have a .net class library which uses NSwag to generate client code from an OpenApi spec, a portion of which is as follows:
"postal_code": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Postal Code"
},
…and when the client code is generated it produces the following type
public partial class Postal_code
{
private System.Collections.Generic.IDictionary<string, object> _additionalProperties;
[Newtonsoft.Json.JsonExtensionData]
public System.Collections.Generic.IDictionary<string, object> AdditionalProperties
{
get { return _additionalProperties ?? (_additionalProperties = new System.Collections.Generic.Dictionary<string, object>()); }
set { _additionalProperties = value; }
}
}
Which is not what I want, I just want Postal_Code
to be represented as a nullable string.
My current config is as below, is there an option I can add to achieve what I’m looking for?
<ItemGroup>
<OpenApiReference Include="OpenApisOpenApiSpec.json" CodeGenerator="NSwagCSharp" Options="/ClientClassAccessModifier:internal" ClassName="NSwagGeneratedClient" />
</ItemGroup>