Skip to content

Commit

Permalink
impl JsonSchema for Schema
Browse files Browse the repository at this point in the history
GREsau committed May 23, 2024

Verified

This commit was signed with the committer’s verified signature.
pradyunsg Pradyun Gedam
1 parent 1819dce commit fe05631
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions schemars/src/schema.rs
Original file line number Diff line number Diff line change
@@ -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<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 {
use serde::ser::{Serialize, SerializeMap, SerializeSeq};
use serde_json::Value;

0 comments on commit fe05631

Please sign in to comment.