JsonSchema2020

Struct JsonSchema2020 

Source
pub struct JsonSchema2020 {
Show 47 fields pub schema: Option<String>, pub id: Option<String>, pub reference: Option<String>, pub dynamic_ref: Option<String>, pub schema_type: Option<TypeArray>, pub title: Option<String>, pub description: Option<String>, pub default: Option<Value>, pub const_value: Option<Value>, pub enum_values: Option<Vec<Value>>, pub min_length: Option<u64>, pub max_length: Option<u64>, pub pattern: Option<String>, pub format: Option<String>, pub minimum: Option<f64>, pub maximum: Option<f64>, pub exclusive_minimum: Option<f64>, pub exclusive_maximum: Option<f64>, pub multiple_of: Option<f64>, pub items: Option<Box<JsonSchema2020>>, pub prefix_items: Option<Vec<JsonSchema2020>>, pub contains: Option<Box<JsonSchema2020>>, pub min_items: Option<u64>, pub max_items: Option<u64>, pub unique_items: Option<bool>, pub properties: Option<HashMap<String, JsonSchema2020>>, pub pattern_properties: Option<HashMap<String, JsonSchema2020>>, pub additional_properties: Option<Box<AdditionalProperties>>, pub required: Option<Vec<String>>, pub property_names: Option<Box<JsonSchema2020>>, pub min_properties: Option<u64>, pub max_properties: Option<u64>, pub all_of: Option<Vec<JsonSchema2020>>, pub any_of: Option<Vec<JsonSchema2020>>, pub one_of: Option<Vec<JsonSchema2020>>, pub not: Option<Box<JsonSchema2020>>, pub if_schema: Option<Box<JsonSchema2020>>, pub then_schema: Option<Box<JsonSchema2020>>, pub else_schema: Option<Box<JsonSchema2020>>, pub deprecated: Option<bool>, pub read_only: Option<bool>, pub write_only: Option<bool>, pub example: Option<Value>, pub examples: Option<Vec<Value>>, pub discriminator: Option<Discriminator>, pub external_docs: Option<ExternalDocumentation>, pub xml: Option<Xml>,
}
Expand description

JSON Schema 2020-12 schema definition

Fields§

§schema: Option<String>

Schema dialect identifier

§id: Option<String>

Schema identifier

§reference: Option<String>

Reference to another schema

§dynamic_ref: Option<String>

Dynamic reference

§schema_type: Option<TypeArray>

Type of the schema

§title: Option<String>

Title of the schema

§description: Option<String>

Description of the schema

§default: Option<Value>

Default value

§const_value: Option<Value>

Constant value

§enum_values: Option<Vec<Value>>

Enum values

§min_length: Option<u64>

Minimum length for strings

§max_length: Option<u64>

Maximum length for strings

§pattern: Option<String>

Pattern for strings

§format: Option<String>

Format hint

§minimum: Option<f64>

Minimum value (inclusive)

§maximum: Option<f64>

Maximum value (inclusive)

§exclusive_minimum: Option<f64>

Exclusive minimum (JSON Schema 2020-12 uses number, not boolean)

§exclusive_maximum: Option<f64>

Exclusive maximum (JSON Schema 2020-12 uses number, not boolean)

§multiple_of: Option<f64>

Multiple of constraint

§items: Option<Box<JsonSchema2020>>

Items schema

§prefix_items: Option<Vec<JsonSchema2020>>

Prefix items (replaces “items” array in draft-07)

§contains: Option<Box<JsonSchema2020>>

Contains constraint

§min_items: Option<u64>

Minimum items

§max_items: Option<u64>

Maximum items

§unique_items: Option<bool>

Unique items

§properties: Option<HashMap<String, JsonSchema2020>>

Object properties

§pattern_properties: Option<HashMap<String, JsonSchema2020>>

Pattern properties

§additional_properties: Option<Box<AdditionalProperties>>

Additional properties

§required: Option<Vec<String>>

Required properties

§property_names: Option<Box<JsonSchema2020>>

Property names schema

§min_properties: Option<u64>

Minimum properties

§max_properties: Option<u64>

Maximum properties

§all_of: Option<Vec<JsonSchema2020>>

All of (must match all schemas)

§any_of: Option<Vec<JsonSchema2020>>

Any of (must match at least one schema)

§one_of: Option<Vec<JsonSchema2020>>

One of (must match exactly one schema)

§not: Option<Box<JsonSchema2020>>

Not (must not match schema)

§if_schema: Option<Box<JsonSchema2020>>

If condition

§then_schema: Option<Box<JsonSchema2020>>

Then schema

§else_schema: Option<Box<JsonSchema2020>>

Else schema

§deprecated: Option<bool>

Whether this property is deprecated

§read_only: Option<bool>

Whether this property is read-only

§write_only: Option<bool>

Whether this property is write-only

§example: Option<Value>

Example value

§examples: Option<Vec<Value>>

Examples (JSON Schema 2020-12)

§discriminator: Option<Discriminator>

OpenAPI discriminator

§external_docs: Option<ExternalDocumentation>

External documentation

§xml: Option<Xml>

XML metadata

Implementations§

Source§

impl JsonSchema2020

Source

pub fn new() -> Self

Create a new empty schema

Source

pub fn string() -> Self

Create a string schema

Source

pub fn number() -> Self

Create a number schema

Source

pub fn integer() -> Self

Create an integer schema

Source

pub fn boolean() -> Self

Create a boolean schema

Source

pub fn array(items: JsonSchema2020) -> Self

Create an array schema

Source

pub fn object() -> Self

Create an object schema

Source

pub fn null() -> Self

Create a null schema

Source

pub fn reference(ref_path: impl Into<String>) -> Self

Create a reference schema

Source

pub fn nullable(self) -> Self

Make this schema nullable

Source

pub fn with_title(self, title: impl Into<String>) -> Self

Add a title

Source

pub fn with_description(self, description: impl Into<String>) -> Self

Add a description

Source

pub fn with_format(self, format: impl Into<String>) -> Self

Add a format

Source

pub fn with_property( self, name: impl Into<String>, schema: JsonSchema2020, ) -> Self

Add a property to an object schema

Source

pub fn with_required(self, name: impl Into<String>) -> Self

Add a required property

Source

pub fn with_example(self, example: Value) -> Self

Add an example

Trait Implementations§

Source§

impl Clone for JsonSchema2020

Source§

fn clone(&self) -> JsonSchema2020

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JsonSchema2020

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for JsonSchema2020

Source§

fn default() -> JsonSchema2020

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for JsonSchema2020

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for JsonSchema2020

Source§

fn eq(&self, other: &JsonSchema2020) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for JsonSchema2020

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for JsonSchema2020

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,