Skip to content

Commit

Permalink
Cover serde_json RawValue type by schemars
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-biel authored and GREsau committed Aug 28, 2023
1 parent 5836afb commit cb392d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions schemars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ uuid = ["uuid08"]
arrayvec = ["arrayvec05"]
indexmap1 = ["indexmap"]

raw_value = ["serde_json/raw_value"]

ui_test = []

[[test]]
Expand Down
13 changes: 13 additions & 0 deletions schemars/src/json_schema_impls/serdejson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,16 @@ impl JsonSchema for Number {
.into()
}
}

#[cfg(feature = "raw_value")]
impl JsonSchema for serde_json::value::RawValue {
no_ref_schema!();

fn schema_name() -> String {
"AnyValue".to_owned()
}

fn json_schema(_: &mut SchemaGenerator) -> Schema {
Schema::Bool(true)
}
}

0 comments on commit cb392d1

Please sign in to comment.