You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C# generator creates all primitive type properties as Nullable<T>. If the property is declared as required in swagger.json should we generate property of type T instead of Nullable<T>?
The required flag is already captured and PrimaryType could be easily extended to support nullability explicitly - SwaggerObject.ToType() method could just use already present IsReguired property.
A config option can be added to turn this behaviour on/off if backwards compatibility is required.
I'm happy to create a PR - just wondering if there are any side-effects I'm not aware of.
The text was updated successfully, but these errors were encountered:
@jkonecki, this was done on purpose. Having nullable primitive types everywhere simplifies logic for PATCH like operations and null validation. Additionally having primitive types in the response insures that deserialization does not throw when the data is missing on the wire (e.g. server changed the field to be nullable but the client was not regenerated with the latest swagger spec).
We still have a validation before serialization for the required fields inside generated methods during runtime.
C# generator creates all primitive type properties as
Nullable<T>
. If the property is declared as required in swagger.json should we generate property of typeT
instead ofNullable<T>
?The required flag is already captured and
PrimaryType
could be easily extended to support nullability explicitly -SwaggerObject.ToType()
method could just use already presentIsReguired
property.A config option can be added to turn this behaviour on/off if backwards compatibility is required.
I'm happy to create a PR - just wondering if there are any side-effects I'm not aware of.
The text was updated successfully, but these errors were encountered: