From 985280c388f3d0aed1f8eb1238ec5d056a7221fa Mon Sep 17 00:00:00 2001 From: Graham Esau Date: Sun, 17 May 2020 10:16:30 +0100 Subject: [PATCH] Make schemars_derive optional --- README.md | 1 + docs/4-features.md | 1 + schemars/Cargo.toml | 8 ++++++-- schemars/src/lib.rs | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cdcb181..750ea48 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,7 @@ fn main() { `#[serde(...)]` attributes can be overriden using `#[schemars(...)]` attributes, which behave identically (e.g. `#[schemars(rename_all = "camelCase")]`). You may find this useful if you want to change the generated schema without affecting Serde's behaviour, or if you're just not using Serde. ## Feature Flags +- `derive` (enabled by default) - provides `#[derive(JsonSchema)]` macro - `impl_json_schema` - implements `JsonSchema` for Schemars types themselves ## Optional Dependencies diff --git a/docs/4-features.md b/docs/4-features.md index 04bb95a..6bfee2f 100644 --- a/docs/4-features.md +++ b/docs/4-features.md @@ -14,6 +14,7 @@ schemars = { version = "0.6", features = ["chrono"] } ``` ## Feature Flags +- `derive` (enabled by default) - provides `#[derive(JsonSchema)]` macro - `impl_json_schema` - implements `JsonSchema` for Schemars types themselves ## Optional Dependencies diff --git a/schemars/Cargo.toml b/schemars/Cargo.toml index 7654f19..3765820 100644 --- a/schemars/Cargo.toml +++ b/schemars/Cargo.toml @@ -13,7 +13,7 @@ categories = ["encoding"] build = "build.rs" [dependencies] -schemars_derive = { version = "=0.7.4", path = "../schemars_derive" } +schemars_derive = { version = "=0.7.4", optional = true, path = "../schemars_derive" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -28,7 +28,11 @@ arrayvec = { version = "0.5", default-features = false, optional = true } pretty_assertions = "0.6.1" [features] -impl_json_schema = [] +default = ["derive"] + +derive = ["schemars_derive"] + +impl_json_schema = ["derive"] # derive_json_schema will be removed in a later version derive_json_schema = ["impl_json_schema"] diff --git a/schemars/src/lib.rs b/schemars/src/lib.rs index b529a8f..fa545d9 100644 --- a/schemars/src/lib.rs +++ b/schemars/src/lib.rs @@ -197,6 +197,7 @@ fn main() { `#[serde(...)]` attributes can be overriden using `#[schemars(...)]` attributes, which behave identically (e.g. `#[schemars(rename_all = "camelCase")]`). You may find this useful if you want to change the generated schema without affecting Serde's behaviour, or if you're just not using Serde. ## Feature Flags +- `derive` (enabled by default) - provides `#[derive(JsonSchema)]` macro - `impl_json_schema` - implements `JsonSchema` for Schemars types themselves ## Optional Dependencies @@ -230,6 +231,7 @@ pub mod gen; /// JSON Schema types. pub mod schema; +#[cfg(feature = "schemars_derive")] pub use schemars_derive::*; // Export serde_json so schemars_derive can use it