predawn_schema/impls/
option.rs1use std::{borrow::Cow, collections::BTreeMap};
2
3use openapiv3::Schema;
4
5use crate::ToSchema;
6
7impl<T: ToSchema> ToSchema for Option<T> {
8 const REQUIRED: bool = false;
9
10 fn title() -> Cow<'static, str> {
11 format!("Option<{}>", T::title()).into()
12 }
13
14 fn schema(
15 schemas: &mut BTreeMap<String, Schema>,
16 schemas_in_progress: &mut Vec<String>,
17 ) -> Schema {
18 let mut schema = T::schema(schemas, schemas_in_progress);
19
20 schema.schema_data.nullable = true;
21 schema.schema_data.title = Some(Self::title().into());
22
23 schema
24 }
25}