utoipa icon indicating copy to clipboard operation
utoipa copied to clipboard

Remove `nullable: true` if the field has `#[serde(skip_serializing_if = "Option::is_none")]`

Open SorenHolstHansen opened this issue 1 year ago • 2 comments

If a field, say my_field: Option<String> is annotated with #[serde(skip_serializing_if = "Option::is_none")] it will serialize to a string, or be removed if it is none. However the generated openapi file still has the field as nullable: true.

Is it possible to remove the nullable on these fields?

SorenHolstHansen avatar Jun 06 '23 13:06 SorenHolstHansen

Should be doable, for now it should be possible to enforce field to non-nullable with #[schema(nullable = false)].

juhaku avatar Oct 31 '23 14:10 juhaku