From ba613b8ac89f8a6528164a84313a52a4c669e57f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Biel?= Date: Thu, 13 Oct 2022 13:09:54 +0200 Subject: [PATCH] Cover serde_json RawValue type by schemars --- schemars/Cargo.toml | 2 ++ schemars/src/json_schema_impls/serdejson.rs | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/schemars/Cargo.toml b/schemars/Cargo.toml index 8470a24f..71403d72 100644 --- a/schemars/Cargo.toml +++ b/schemars/Cargo.toml @@ -60,6 +60,8 @@ uuid = ["uuid08"] arrayvec = ["arrayvec05"] indexmap1 = ["indexmap"] +raw_value = ["serde_json/raw_value"] + ui_test = [] [[test]] diff --git a/schemars/src/json_schema_impls/serdejson.rs b/schemars/src/json_schema_impls/serdejson.rs index d0cceff6..df6ad497 100644 --- a/schemars/src/json_schema_impls/serdejson.rs +++ b/schemars/src/json_schema_impls/serdejson.rs @@ -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) + } +}