Struct salvo_oapi::schema::Object

source ·
#[non_exhaustive]
pub struct Object {
Show 25 fields pub schema_type: SchemaType, pub name: Option<String>, pub format: Option<SchemaFormat>, pub description: Option<String>, pub default_value: Option<Value>, pub enum_values: Option<Vec<Value>>, pub required: IndexSet<String>, pub properties: PropMap<String, RefOr<Schema>>, pub additional_properties: Option<Box<AdditionalProperties<Schema>>>, pub deprecated: Option<Deprecated>, pub example: Option<Value>, pub write_only: Option<bool>, pub read_only: Option<bool>, pub xml: Option<Xml>, pub nullable: bool, pub multiple_of: Option<f64>, pub maximum: Option<f64>, pub minimum: Option<f64>, pub exclusive_maximum: Option<f64>, pub exclusive_minimum: Option<f64>, pub max_length: Option<usize>, pub min_length: Option<usize>, pub pattern: Option<String>, pub max_properties: Option<usize>, pub min_properties: Option<usize>,
}
Expand description

Implements subset of OpenAPI Schema Object which allows adding other Schemas as properties to this Schema.

This is a generic OpenAPI schema object which can used to present object, field or an enum.

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.
§schema_type: SchemaType

Type of Object e.g. SchemaType::Object for object and SchemaType::String for string types.

§name: Option<String>

Changes the Object name.

§format: Option<SchemaFormat>

Additional format for detailing the schema type.

§description: Option<String>

Description of the Object. Markdown syntax is supported.

§default_value: Option<Value>

Default value which is provided when user has not provided the input in Swagger UI.

§enum_values: Option<Vec<Value>>

Enum variants of fields that can be represented as unit type enums

§required: IndexSet<String>

Vector of required field names.

§properties: PropMap<String, RefOr<Schema>>

Map of fields with their Schema types.

With preserve-order feature flag indexmap::IndexMap will be used as properties map backing implementation to retain property order of ToSchema. By default BTreeMap will be used.

§additional_properties: Option<Box<AdditionalProperties<Schema>>>

Additional Schema for non specified fields (Useful for typed maps).

§deprecated: Option<Deprecated>

Changes the Object deprecated status.

§example: Option<Value>

Example shown in UI of the value for richer documentation.

§write_only: Option<bool>

Write only property will be only sent in write requests like POST, PUT.

§read_only: Option<bool>

Read only property will be only sent in read requests like GET.

§xml: Option<Xml>

Additional Xml formatting of the Object.

§nullable: bool

Set true to allow "null" to be used as value for given type.

§multiple_of: Option<f64>

Must be a number strictly greater than 0. Numeric value is considered valid if value divided by the multiple_of value results an integer.

§maximum: Option<f64>

Specify inclusive upper limit for the Object’s value. Number is considered valid if it is equal or less than the maximum.

§minimum: Option<f64>

Specify inclusive lower limit for the Object’s value. Number value is considered valid if it is equal or greater than the minimum.

§exclusive_maximum: Option<f64>

Specify exclusive upper limit for the Object’s value. Number value is considered valid if it is strictly less than exclusive_maximum.

§exclusive_minimum: Option<f64>

Specify exclusive lower limit for the Object’s value. Number value is considered valid if it is strictly above the exclusive_minimum.

§max_length: Option<usize>

Specify maximum length for string values. max_length cannot be a negative integer value. Value is considered valid if content length is equal or less than the max_length.

§min_length: Option<usize>

Specify minimum length for string values. min_length cannot be a negative integer value. Setting this to 0 has the same effect as omitting this field. Value is considered valid if content length is equal or more than the min_length.

§pattern: Option<String>

Define a valid ECMA-262 dialect regular expression. The string content is considered valid if the pattern matches the value successfully.

§max_properties: Option<usize>

Specify inclusive maximum amount of properties an Object can hold.

§min_properties: Option<usize>

Specify inclusive minimum amount of properties an Object can hold. Setting this to 0 will have same effect as omitting the attribute.

Implementations§

source§

impl Object

source

pub fn new() -> Self

Initialize a new Object with default SchemaType. This effectively same as calling Object::with_type(SchemaType::Object).

source

pub fn with_type(schema_type: SchemaType) -> Self

Initialize new Object with given SchemaType.

Create std::string object type which can be used to define string field of an object.

let object = Object::with_type(SchemaType::String);
source

pub fn schema_type(self, schema_type: SchemaType) -> Self

Add or change type of the object e.g SchemaType::String.

source

pub fn format(self, format: SchemaFormat) -> Self

Add or change additional format for detailing the schema type.

source

pub fn property<S: Into<String>, I: Into<RefOr<Schema>>>( self, property_name: S, component: I, ) -> Self

Add new property to the Object.

Method accepts property name and property component as an arguments.

source

pub fn additional_properties<I: Into<AdditionalProperties<Schema>>>( self, additional_properties: I, ) -> Self

Add additional properties to the Object.

source

pub fn required(self, required_field: impl Into<String>) -> Self

Add field to the required fields of Object.

source

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

Add or change the name of the Object.

source

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

Add or change description of the property. Markdown syntax is supported.

source

pub fn default_value(self, default: Value) -> Self

Add or change default value for the object which is provided when user has not provided the input in Swagger UI.

source

pub fn deprecated(self, deprecated: Deprecated) -> Self

Add or change deprecated status for Object.

source

pub fn enum_values<I, E>(self, enum_values: I) -> Self
where I: IntoIterator<Item = E>, E: Into<Value>,

Add or change enum property variants.

source

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

Add or change example shown in UI of the value for richer documentation.

source

pub fn write_only(self, write_only: bool) -> Self

Add or change write only flag for Object.

source

pub fn read_only(self, read_only: bool) -> Self

Add or change read only flag for Object.

source

pub fn xml(self, xml: Xml) -> Self

Add or change additional Xml formatting of the Object.

source

pub fn nullable(self, nullable: bool) -> Self

Add or change nullable flag for Object.

source

pub fn multiple_of(self, multiple_of: f64) -> Self

Set or change multiple_of validation flag for number and integer type values.

source

pub fn maximum(self, maximum: f64) -> Self

Set or change inclusive maximum value for number and integer values.

source

pub fn minimum(self, minimum: f64) -> Self

Set or change inclusive minimum value for number and integer values.

source

pub fn exclusive_maximum(self, exclusive_maximum: f64) -> Self

Set or change exclusive maximum value for number and integer values.

source

pub fn exclusive_minimum(self, exclusive_minimum: f64) -> Self

Set or change exclusive minimum value for number and integer values.

source

pub fn max_length(self, max_length: usize) -> Self

Set or change maximum length for string values.

source

pub fn min_length(self, min_length: usize) -> Self

Set or change minimum length for string values.

source

pub fn pattern<I: Into<String>>(self, pattern: I) -> Self

Set or change a valid regular expression for string value to match.

source

pub fn max_properties(self, max_properties: usize) -> Self

Set or change maximum number of properties the Object can hold.

source

pub fn min_properties(self, min_properties: usize) -> Self

Set or change minimum number of properties the Object can hold.

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

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 AdditionalProperties<Schema>

source§

fn from(value: Object) -> Self

Converts to this type from the input type.
source§

impl From<Object> for RefOr<Schema>

source§

fn from(obj: Object) -> Self

Converts to this type from the input type.
source§

impl From<Object> for Schema

source§

fn from(s: Object) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Object

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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 ToArray for Object

source§

fn to_array(self) -> Array

Convert a type to Array.
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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

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

source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T