schemars/json_schema_impls/
serdejson.rs
1use crate::gen::SchemaGenerator;
2use crate::schema::*;
3use crate::JsonSchema;
4use serde_json::{Map, Number, Value};
5use std::borrow::Cow;
6use std::collections::BTreeMap;
7
8impl JsonSchema for Value {
9 no_ref_schema!();
10
11 fn schema_name() -> String {
12 "AnyValue".to_owned()
13 }
14
15 fn schema_id() -> Cow<'static, str> {
16 Cow::Borrowed("AnyValue")
17 }
18
19 fn json_schema(_: &mut SchemaGenerator) -> Schema {
20 Schema::Bool(true)
21 }
22}
23
24forward_impl!(Map<String, Value> => BTreeMap<String, Value>);
25
26impl JsonSchema for Number {
27 no_ref_schema!();
28
29 fn schema_name() -> String {
30 "Number".to_owned()
31 }
32
33 fn schema_id() -> Cow<'static, str> {
34 Cow::Borrowed("Number")
35 }
36
37 fn json_schema(_: &mut SchemaGenerator) -> Schema {
38 SchemaObject {
39 instance_type: Some(InstanceType::Number.into()),
40 ..Default::default()
41 }
42 .into()
43 }
44}
45
46#[cfg(feature = "raw_value")]
47forward_impl!(serde_json::value::RawValue => Value);