Revert "api/schema.rs: avoid Option(Option( nesting"

This reverts commit ffdac1af01.
This commit is contained in:
Dietmar Maurer 2019-01-19 12:52:51 +01:00
parent ca3d861513
commit 80f069656d

View File

@ -281,17 +281,7 @@ impl ObjectSchema {
} }
pub fn optional<S: Into<Arc<Schema>>>(mut self, name: &'static str, schema: S) -> Self { pub fn optional<S: Into<Arc<Schema>>>(mut self, name: &'static str, schema: S) -> Self {
let schema = schema.into(); self.properties.insert(name, Arc::new(Schema::Option(schema.into())));
let is_option = match schema.as_ref() {
Schema::Option(_) => true,
_ => false,
};
if is_option {
self.properties.insert(name, schema);
} else {
self.properties.insert(name, Arc::new(Schema::Option(schema)));
}
self self
} }
} }