impl JsonSchema for Schema

This commit is contained in:
Graham Esau 2024-05-23 17:44:50 +01:00
parent 1819dceb24
commit fe05631f21

View file

@ -2,8 +2,7 @@
JSON Schema types. JSON Schema types.
*/ */
use ref_cast::ref_cast_custom; use ref_cast::{ref_cast_custom, RefCastCustom};
use ref_cast::RefCastCustom;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::{Map, Value}; use serde_json::{Map, Value};
@ -175,6 +174,22 @@ impl From<bool> for Schema {
} }
} }
impl crate::JsonSchema for Schema {
fn schema_name() -> String {
"Schema".to_owned()
}
fn schema_id() -> std::borrow::Cow<'static, str> {
"schemars::Schema".into()
}
fn json_schema(_: &mut crate::gen::SchemaGenerator) -> Schema {
crate::json_schema!({
"type": ["object", "boolean"]
})
}
}
mod ser { mod ser {
use serde::ser::{Serialize, SerializeMap, SerializeSeq}; use serde::ser::{Serialize, SerializeMap, SerializeSeq};
use serde_json::Value; use serde_json::Value;