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
This means { variable: null } is returned if it is a None in Rust.
However, the implementation of the Type trait for Option<T> simply passes all implementations to T, except for IS_REQUIRED, which is set to false. For example:
I believe this is a mismatch. The generated openapi spec suggests the field field1 either IS there and is a string, or isn't there at all, but the ToJSON impl will ensure the field is always there, but is possibly null.
As far as I can see there's two options (heh) here:
Use the nullable annotation for options in the openapi spec
Don't return Value::Null in the ToJSON impl of Option<T>, but return None
I'm interested in your thoughts!
The text was updated successfully, but these errors were encountered:
The ToJSON for an
Option<T>
is implemented as follows:This means
{ variable: null }
is returned if it is aNone
in Rust.However, the implementation of the
Type
trait forOption<T>
simply passes all implementations toT
, except forIS_REQUIRED
, which is set tofalse
. For example:leads to the following openapi spec:
I believe this is a mismatch. The generated openapi spec suggests the field
field1
either IS there and is a string, or isn't there at all, but theToJSON
impl will ensure the field is always there, but is possibly null.As far as I can see there's two options (heh) here:
nullable
annotation for options in the openapi specValue::Null
in theToJSON
impl ofOption<T>
, but returnNone
I'm interested in your thoughts!
The text was updated successfully, but these errors were encountered: