autorest
autorest copied to clipboard
Compatibility: Does the client include a property that has a null value?
If I add a new foo
property with type integer
and x-nullable: true
in the Swagger definition, will the generated client send "foo": null
in the request payload? Or will foo
be absent from the payload?
The reason I'm asking is that I'm not sure if existing server versions will tolerate an extraneous property with an explicit null
in the payload.
Do you want to describe optional properties or nullable? x-nullable
will technically mean you can set it to null
over the wire. For optional properties they should just not be part of teh required: []
array
Do you want to describe optional properties or nullable?
x-nullable
will technically mean you can set it tonull
over the wire. For optional properties they should just not be part of tehrequired: []
array
The property is both optional and nullable.
By that you mean in your backend or over the wire? From your original message you said you are not sure if null
would be accepted over the wire.
If you are doing a CSharp server that use null to represent optionality then what you want is to define the property as optional. Nullable properties should be extremely rare and only used in case like json merge patch for Microsoft services.