From fe05631f214416ceba756d8a464eebcb742a0c42 Mon Sep 17 00:00:00 2001 From: Graham Esau Date: Thu, 23 May 2024 17:44:50 +0100 Subject: [PATCH] impl JsonSchema for Schema --- schemars/src/schema.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/schemars/src/schema.rs b/schemars/src/schema.rs index 27cb048..6eb55e8 100644 --- a/schemars/src/schema.rs +++ b/schemars/src/schema.rs @@ -2,8 +2,7 @@ JSON Schema types. */ -use ref_cast::ref_cast_custom; -use ref_cast::RefCastCustom; +use ref_cast::{ref_cast_custom, RefCastCustom}; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; @@ -175,6 +174,22 @@ impl From 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 { use serde::ser::{Serialize, SerializeMap, SerializeSeq}; use serde_json::Value;