Rename derive_json_schema feature to impl_json_schema
This commit is contained in:
parent
1c0f626e3f
commit
0ae2d48fba
5 changed files with 20 additions and 18 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ schemars = { version = "0.6", features = ["chrono"] }
|
|||
|
||||
<div class="indented">
|
||||
|
||||
### derive_json_schema
|
||||
### impl_json_schema
|
||||
|
||||
Implements `JsonSchema` on Schemars types themselves.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<bool> 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<Schema> 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<T> {
|
||||
Single(Box<T>),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue