0

I'm looking for a way to have nswag generate a C# client for me that generates nullables for nullable primitives and all non-primitives, but not for non-nullable primitives.

Say I have a C# object such as

public bool NonNullableBool { get; set; }
public SomeClass NonPrimitive { get; set; }
public bool? NullableBool { get; set; }
public SomeOtherClass AnotherNonPrimitive { get; set; }
public string SomeString { get; set; }

By default, when nswag generates a client and models for this object, it generates a match, such as

public bool NonNullableBool { get; set; }
public SomeClass NonPrimitive { get; set; }
public bool? NullableBool { get; set; }
public SomeOtherClass AnotherNonPrimitive { get; set; }
public string SomeString { get; set; }

Which is great. If I add the GenerateNullableReferenceTypes:true flag to my command, it generates with everything nullable, such as

public bool? NonNullableBool { get; set; }
public SomeClass? NonPrimitive { get; set; }
public bool? NullableBool { get; set; }
public SomeOtherClass? AnotherNonPrimitive { get; set; }
public string? SomeString { get; set; }

What I'm looking for is

public bool NonNullableBool { get; set; }
public SomeClass? NonPrimitive { get; set; }
public bool? NullableBool { get; set; }
public SomeOtherClass? AnotherNonPrimitive { get; set; }
public string SomeString { get; set; }

Is there a way to do this?

0 Answers0