Make schemars_derive optional

This commit is contained in:
Graham Esau 2020-05-17 10:16:30 +01:00
parent 5a28cef598
commit 985280c388
4 changed files with 10 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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"]

View file

@ -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