diff --git a/README.md b/README.md index 7945910..b86e2ff 100644 --- a/README.md +++ b/README.md @@ -208,5 +208,5 @@ fn main() { ## Feature Flags - `chrono` - implements `JsonSchema` for all [Chrono](https://github.com/chronotope/chrono) types which are serializable by Serde. -- `derive_json_schema` - implements `JsonSchema` for Schemars types themselves +- `impl_json_schema` - implements `JsonSchema` for Schemars types themselves diff --git a/docs/4-features.md b/docs/4-features.md index e3bdfb5..93bb7b9 100644 --- a/docs/4-features.md +++ b/docs/4-features.md @@ -15,7 +15,7 @@ schemars = { version = "0.6", features = ["chrono"] }
-### derive_json_schema +### impl_json_schema Implements `JsonSchema` on Schemars types themselves. diff --git a/schemars/Cargo.toml b/schemars/Cargo.toml index 1b1adcc..d2d0013 100644 --- a/schemars/Cargo.toml +++ b/schemars/Cargo.toml @@ -22,7 +22,9 @@ chrono = { version = "0.4", default-features = false, optional = true } pretty_assertions = "0.6.1" [features] -derive_json_schema = [] +impl_json_schema = [] +# derive_json_schema will be removed in a later version +derive_json_schema = ["impl_json_schema"] [[test]] name = "chrono" @@ -30,7 +32,7 @@ required-features = ["chrono"] [[test]] name = "schema_for_schema" -required-features = ["derive_json_schema"] +required-features = ["impl_json_schema"] [package.metadata.docs.rs] all-features = true diff --git a/schemars/src/lib.rs b/schemars/src/lib.rs index 0a2e4dc..af08336 100644 --- a/schemars/src/lib.rs +++ b/schemars/src/lib.rs @@ -202,7 +202,7 @@ fn main() { ## Feature Flags - `chrono` - implements `JsonSchema` for all [Chrono](https://github.com/chronotope/chrono) types which are serializable by Serde. -- `derive_json_schema` - implements `JsonSchema` for Schemars types themselves +- `impl_json_schema` - implements `JsonSchema` for Schemars types themselves */ /// The map type used by schemars types. diff --git a/schemars/src/schema.rs b/schemars/src/schema.rs index b194ea4..bd0189a 100644 --- a/schemars/src/schema.rs +++ b/schemars/src/schema.rs @@ -1,6 +1,6 @@ -#[cfg(feature = "derive_json_schema")] +#[cfg(feature = "impl_json_schema")] use crate as schemars; -#[cfg(feature = "derive_json_schema")] +#[cfg(feature = "impl_json_schema")] use crate::JsonSchema; use crate::{Map, Set}; use serde::{Deserialize, Serialize}; @@ -9,7 +9,7 @@ use serde_json::Value; /// A JSON Schema. #[allow(clippy::large_enum_variant)] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -#[cfg_attr(feature = "derive_json_schema", derive(JsonSchema))] +#[cfg_attr(feature = "impl_json_schema", derive(JsonSchema))] #[serde(untagged)] pub enum Schema { /// A trivial boolean JSON Schema. @@ -56,7 +56,7 @@ impl From for Schema { /// The root object of a JSON Schema document. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)] -#[cfg_attr(feature = "derive_json_schema", derive(JsonSchema))] +#[cfg_attr(feature = "impl_json_schema", derive(JsonSchema))] #[serde(rename_all = "camelCase", default)] pub struct RootSchema { /// The `$schema` keyword. @@ -78,7 +78,7 @@ pub struct RootSchema { /// A JSON Schema object. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)] -#[cfg_attr(feature = "derive_json_schema", derive(JsonSchema))] +#[cfg_attr(feature = "impl_json_schema", derive(JsonSchema))] #[serde(rename_all = "camelCase", default)] pub struct SchemaObject { /// Properties which annotate the [`SchemaObject`] which typically have no effect when an object is being validated against the schema. @@ -218,7 +218,7 @@ impl From for SchemaObject { /// Properties which annotate a [`SchemaObject`] which typically have no effect when an object is being validated against the schema. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)] -#[cfg_attr(feature = "derive_json_schema", derive(JsonSchema))] +#[cfg_attr(feature = "impl_json_schema", derive(JsonSchema))] #[serde(rename_all = "camelCase", default)] pub struct Metadata { /// The `$id` keyword. @@ -268,7 +268,7 @@ fn is_false(b: &bool) -> bool { /// Properties of a [`SchemaObject`] which define validation assertions in terms of other schemas. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)] -#[cfg_attr(feature = "derive_json_schema", derive(JsonSchema))] +#[cfg_attr(feature = "impl_json_schema", derive(JsonSchema))] #[serde(rename_all = "camelCase", default)] pub struct SubschemaValidation { /// The `allOf` keyword. @@ -310,7 +310,7 @@ pub struct SubschemaValidation { /// Properties of a [`SchemaObject`] which define validation assertions for numbers. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)] -#[cfg_attr(feature = "derive_json_schema", derive(JsonSchema))] +#[cfg_attr(feature = "impl_json_schema", derive(JsonSchema))] #[serde(rename_all = "camelCase", default)] pub struct NumberValidation { /// The `multipleOf` keyword. @@ -342,7 +342,7 @@ pub struct NumberValidation { /// Properties of a [`SchemaObject`] which define validation assertions for strings. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)] -#[cfg_attr(feature = "derive_json_schema", derive(JsonSchema))] +#[cfg_attr(feature = "impl_json_schema", derive(JsonSchema))] #[serde(rename_all = "camelCase", default)] pub struct StringValidation { /// The `maxLength` keyword. @@ -364,7 +364,7 @@ pub struct StringValidation { /// Properties of a [`SchemaObject`] which define validation assertions for arrays. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)] -#[cfg_attr(feature = "derive_json_schema", derive(JsonSchema))] +#[cfg_attr(feature = "impl_json_schema", derive(JsonSchema))] #[serde(rename_all = "camelCase", default)] pub struct ArrayValidation { /// The `items` keyword. @@ -401,7 +401,7 @@ pub struct ArrayValidation { /// Properties of a [`SchemaObject`] which define validation assertions for objects. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)] -#[cfg_attr(feature = "derive_json_schema", derive(JsonSchema))] +#[cfg_attr(feature = "impl_json_schema", derive(JsonSchema))] #[serde(rename_all = "camelCase", default)] pub struct ObjectValidation { /// The `maxProperties` keyword. @@ -445,7 +445,7 @@ pub struct ObjectValidation { /// /// See [JSON Schema 4.2.1. Instance Data Model](https://tools.ietf.org/html/draft-handrews-json-schema-02#section-4.2.1). #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "derive_json_schema", derive(JsonSchema))] +#[cfg_attr(feature = "impl_json_schema", derive(JsonSchema))] #[serde(rename_all = "camelCase")] pub enum InstanceType { Null, @@ -461,7 +461,7 @@ pub enum InstanceType { /// /// In some contexts, a `Single` may be semantically distinct from a `Vec` containing only item. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "derive_json_schema", derive(JsonSchema))] +#[cfg_attr(feature = "impl_json_schema", derive(JsonSchema))] #[serde(untagged)] pub enum SingleOrVec { Single(Box),