Struct Object

Source
#[non_exhaustive]
pub struct Object {
Show 56 fields pub properties: IndexMap<String, Schema>, pub examples: Vec<Value>, pub prefix_items: Option<Vec<Schema>>, pub enum_values: Option<Vec<Value>>, pub required: Vec<String>, pub all_of: Vec<Schema>, pub any_of: Option<Vec<Schema>>, pub one_of: Option<Vec<Schema>>, pub id: String, pub schema: Option<Schema>, pub reference: String, pub comment: String, pub title: String, pub description: String, pub summary: String, pub default: Option<Value>, pub read_only: Option<bool>, pub deprecated: Option<bool>, pub write_only: Option<bool>, pub multiple_of: Option<OrderedFloat<f64>>, pub maximum: Option<OrderedFloat<f64>>, pub exclusive_maximum: Option<OrderedFloat<f64>>, pub minimum: Option<OrderedFloat<f64>>, pub exclusive_minimum: Option<OrderedFloat<f64>>, pub max_length: Option<u64>, pub min_length: Option<u64>, pub pattern: Option<String>, pub additional_items: Option<Schema>, pub items: Option<Schema>, pub max_items: Option<u64>, pub min_items: Option<u64>, pub unique_items: Option<bool>, pub contains: Option<Schema>, pub max_properties: Option<u64>, pub min_properties: Option<u64>, pub max_contains: Option<u64>, pub min_contains: Option<u64>, pub additional_properties: Option<Schema>, pub definitions: IndexMap<String, Schema>, pub pattern_properties: IndexMap<String, Schema>, pub dependencies: IndexMap<String, Schema>, pub property_names: Option<Schema>, pub const_value: Option<Value>, pub schema_type: Option<Types>, pub format: String, pub content_media_type: String, pub content_encoding: String, pub content_schema: Option<Schema>, pub if_cond: Option<Schema>, pub then: Option<Schema>, pub else_cond: Option<Schema>, pub not: Option<Schema>, pub unevaluated_items: Option<Schema>, pub unevaluated_properties: Option<Schema>, pub discriminator: Option<Discriminator>, pub extensions: Option<Extensions>,
}
Expand description

A JSON Schema Object as per JSON Schema specification. https://www.learnjsonschema.com/2020-12/

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§properties: IndexMap<String, Schema>

The properties keyword restricts object properties to the given subschemas. Collected annotations report which properties were evaluated. https://www.learnjsonschema.com/2020-12/applicator/properties/

§examples: Vec<Value>

The examples keyword provides example instances for documentation. Does not affect validation. https://www.learnjsonschema.com/2020-12/meta-data/examples/

§prefix_items: Option<Vec<Schema>>

The prefixItems keyword validates the first items of an array against a sequence of subschemas. Remaining items fall back to items, if present. https://www.learnjsonschema.com/2020-12/applicator/prefixitems/

§enum_values: Option<Vec<Value>>

The enum keyword restricts instances to a finite set of values. https://www.learnjsonschema.com/2020-12/validation/enum/

§required: Vec<String>

The required keyword lists property names that must be present in an object. https://www.learnjsonschema.com/2020-12/applicator/required/

§all_of: Vec<Schema>

The allOf keyword requires instance validation against all subschemas. https://www.learnjsonschema.com/2020-12/validation/allof/

§any_of: Option<Vec<Schema>>

The anyOf keyword requires validation against at least one subschema. https://www.learnjsonschema.com/2020-12/validation/anyof/

§one_of: Option<Vec<Schema>>

The oneOf keyword requires validation against exactly one subschema. https://www.learnjsonschema.com/2020-12/validation/oneof/

§id: String

The $id keyword defines a unique identifier for the schema. https://www.learnjsonschema.com/2020-12/meta-data/id/

§schema: Option<Schema>

The $schema keyword declares the JSON Schema version. https://www.learnjsonschema.com/2020-12/meta-data/schema/

§reference: String

The $ref keyword references an external or internal schema by URI. https://www.learnjsonschema.com/2020-12/structure/$ref/

§comment: String

The $comment keyword provides annotations for documentation. https://www.learnjsonschema.com/2020-12/meta-data/comment/

§title: String

The title keyword provides a short descriptive title. https://www.learnjsonschema.com/2020-12/meta-data/title/

§description: String

The description keyword provides a detailed description. https://www.learnjsonschema.com/2020-12/meta-data/description/

§summary: String

The summary keyword offers a brief summary for documentation. https://www.learnjsonschema.com/2020-12/meta-data/summary/

§default: Option<Value>

The default keyword provides a default instance value. https://www.learnjsonschema.com/2020-12/validation/default/

§read_only: Option<bool>

The readOnly keyword marks a property as read-only. https://www.learnjsonschema.com/2020-12/validation/readOnly/

§deprecated: Option<bool>

The deprecated keyword marks a schema as deprecated. https://www.learnjsonschema.com/2020-12/meta-data/deprecated/

§write_only: Option<bool>

The writeOnly keyword marks a property as write-only. https://www.learnjsonschema.com/2020-12/validation/writeOnly/

§multiple_of: Option<OrderedFloat<f64>>

The multipleOf keyword ensures the number is a multiple of this value. https://www.learnjsonschema.com/2020-12/validation/multipleOf/

§maximum: Option<OrderedFloat<f64>>

The maximum keyword defines the maximum numeric value. https://www.learnjsonschema.com/2020-12/validation/maximum/

§exclusive_maximum: Option<OrderedFloat<f64>>

The exclusiveMaximum keyword requires the number to be less than this value. https://www.learnjsonschema.com/2020-12/validation/exclusiveMaximum/

§minimum: Option<OrderedFloat<f64>>

The minimum keyword defines the minimum numeric value. https://www.learnjsonschema.com/2020-12/validation/minimum/

§exclusive_minimum: Option<OrderedFloat<f64>>

The exclusiveMinimum keyword requires the number to be greater than this value. https://www.learnjsonschema.com/2020-12/validation/exclusiveMinimum/

§max_length: Option<u64>

The maxLength keyword restricts string length to at most this value. https://www.learnjsonschema.com/2020-12/validation/maxLength/

§min_length: Option<u64>

The minLength keyword restricts string length to at least this value. https://www.learnjsonschema.com/2020-12/validation/minLength/

§pattern: Option<String>

The pattern keyword restricts strings to those matching this regular expression. https://www.learnjsonschema.com/2020-12/validation/pattern/

§additional_items: Option<Schema>

The additionalItems keyword defines the schema for array elements beyond those covered by a tuple definition. https://www.learnjsonschema.com/2020-12/applicator/additionalItems/

§items: Option<Schema>

The items keyword restricts all elements in an array to this schema, or provides a tuple of schemas for positional validation. https://www.learnjsonschema.com/2020-12/applicator/items/

§max_items: Option<u64>

The maxItems keyword restricts the number of elements in an array to at most this value. https://www.learnjsonschema.com/2020-12/validation/maxItems/

§min_items: Option<u64>

The minItems keyword restricts the number of elements in an array to at least this value. https://www.learnjsonschema.com/2020-12/validation/minItems/

§unique_items: Option<bool>

The uniqueItems keyword ensures that all elements in an array are unique. https://www.learnjsonschema.com/2020-12/validation/uniqueItems/

§contains: Option<Schema>

The contains keyword ensures that at least one element in the array matches the specified schema. https://www.learnjsonschema.com/2020-12/applicator/contains/

§max_properties: Option<u64>

The maxProperties keyword restricts the number of properties in an object to at most this value. https://www.learnjsonschema.com/2020-12/validation/maxProperties/

§min_properties: Option<u64>

The minProperties keyword restricts the number of properties in an object to at least this value. https://www.learnjsonschema.com/2020-12/validation/minProperties/

§max_contains: Option<u64>

The maxContains keyword limits how many items matching contains may appear in an array. https://www.learnjsonschema.com/2020-12/applicator/maxContains/

§min_contains: Option<u64>

The minContains keyword requires at least this many items matching contains in an array. https://www.learnjsonschema.com/2020-12/applicator/minContains/

§additional_properties: Option<Schema>

The additionalProperties keyword defines the schema for object properties not explicitly listed. https://www.learnjsonschema.com/2020-12/applicator/additionalProperties/

§definitions: IndexMap<String, Schema>

The definitions section holds reusable schema definitions for reference. https://www.learnjsonschema.com/2020-12/meta-data/definitions/

§pattern_properties: IndexMap<String, Schema>

The patternProperties keyword maps regex patterns to schemas for matching property names. https://www.learnjsonschema.com/2020-12/applicator/patternProperties/

§dependencies: IndexMap<String, Schema>

The dependencies keyword specifies schema or property dependencies for an object. https://www.learnjsonschema.com/2020-12/applicator/dependencies/

§property_names: Option<Schema>

The propertyNames keyword restricts all property names in an object to match this schema. https://www.learnjsonschema.com/2020-12/applicator/propertyNames/

§const_value: Option<Value>

The const keyword requires the instance to be exactly this value. https://www.learnjsonschema.com/2020-12/validation/const/

§schema_type: Option<Types>

The type keyword restricts the instance to the specified JSON types. https://www.learnjsonschema.com/2020-12/validation/type/

§format: String

The format keyword provides semantic validation hints, such as “email” or “date-time”. https://www.learnjsonschema.com/2020-12/meta-data/format/

§content_media_type: String

The contentMediaType annotation describes the media type for string content. https://www.learnjsonschema.com/2020-12/annotations/contentMediaType/

§content_encoding: String

The contentEncoding annotation describes the encoding (e.g., “base64”) for string content. https://www.learnjsonschema.com/2020-12/annotations/contentEncoding/

§content_schema: Option<Schema>

The contentSchema annotation defines a schema for binary media represented as a string. https://www.learnjsonschema.com/2020-12/applicator/contentSchema/

§if_cond: Option<Schema>

The if keyword applies conditional schema validation when this subschema is valid. https://www.learnjsonschema.com/2020-12/applicator/if/

§then: Option<Schema>

The then keyword applies this subschema when the if condition is met. https://www.learnjsonschema.com/2020-12/applicator/then/

§else_cond: Option<Schema>

The else keyword applies this subschema when the if condition is not met. https://www.learnjsonschema.com/2020-12/applicator/else/

§not: Option<Schema>

The not keyword ensures the instance does not match this subschema. https://www.learnjsonschema.com/2020-12/applicator/not/

§unevaluated_items: Option<Schema>

The unevaluatedItems keyword applies schemas to items not covered by items or contains. https://www.learnjsonschema.com/2020-12/applicator/unevaluatedItems/

§unevaluated_properties: Option<Schema>

The unevaluatedProperties keyword applies schemas to properties not covered by properties or pattern-based keywords. https://www.learnjsonschema.com/2020-12/applicator/unevaluatedProperties/

§discriminator: Option<Discriminator>

The discriminator keyword provides object property-based type differentiation (OpenAPI). https://spec.openapis.org/oas/v3.1.0#discriminator-object

§extensions: Option<Extensions>

All additional, unrecognized fields are stored here as extensions.

Implementations§

Source§

impl Object

Source

pub fn builder() -> ObjectBuilder

Create an instance of Object using the builder syntax

Source§

impl Object

Source

pub fn with_type(ty: impl Into<Types>) -> ObjectBuilder<SetSchemaType>

Create a new object builder with the schema type. Short hand for

Object::builder().schema_type(ty)
Source

pub fn int32() -> Object

An object that represents an i32

Source

pub fn int64() -> Object

An object that represents an i64

Source

pub fn uint32() -> Object

An object that represents an u32

Source

pub fn uint64() -> Object

An object that represents an u64

Source

pub fn to_array(self) -> Self

Convert the object into an array of that type.

Source

pub fn all_ofs<S: Into<Schema>>(all_ofs: impl IntoIterator<Item = S>) -> Object

Builds a new object where its an aggregate of all the objects in the iterator. Short hand for

Object::builder().all_ofs(all_ofs).build()
Source§

impl Object

Source

pub fn optimize(&mut self)

Optimize the openapi schema This will compress nested allOfs and try merge things together.

Source

pub fn into_optimized(self) -> Self

Convert the value into an optimized version of itself.

Source

pub fn is_empty(&self) -> bool

Returns true if the object is in the default state.

Trait Implementations§

Source§

impl Clone for Object

Source§

fn clone(&self) -> Object

Returns a copy 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 Object

Source§

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

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

impl Default for Object

Source§

fn default() -> Object

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

impl<'de> Deserialize<'de> for Object
where Object: Default,

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 From<Object> for Schema

Source§

fn from(value: Object) -> Self

Converts to this type from the input type.
Source§

impl<S: IsComplete> From<ObjectBuilder<S>> for Object

Source§

fn from(value: ObjectBuilder<S>) -> Self

Converts to this type from the input type.
Source§

impl From<Ref> for Object

Source§

fn from(value: Ref) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Object

Source§

fn eq(&self, other: &Object) -> 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 Object

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 Object

Auto Trait Implementations§

§

impl Freeze for Object

§

impl RefUnwindSafe for Object

§

impl Send for Object

§

impl Sync for Object

§

impl Unpin for Object

§

impl UnwindSafe for Object

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