Struct salvo_oapi::schema::Object
source · #[non_exhaustive]pub struct Object {Show 25 fields
pub schema_type: SchemaType,
pub symbol: Option<String>,
pub format: Option<SchemaFormat>,
pub description: Option<String>,
pub default: Option<Value>,
pub enum_values: Option<Vec<Value>>,
pub required: Vec<String>,
pub properties: BTreeMap<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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.schema_type: SchemaTypeType of Object e.g. SchemaType::Object for object and SchemaType::String for
string types.
symbol: Option<String>Changes the Object symbol.
format: Option<SchemaFormat>Additional format for detailing the schema type.
description: Option<String>Description of the Object. Markdown syntax is supported.
default: 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: Vec<String>Vector of required field names.
properties: BTreeMap<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>§nullable: boolSet 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
impl Object
sourcepub fn new() -> Self
pub fn new() -> Self
Initialize a new Object with default SchemaType. This effectively same as calling
Object::with_type(SchemaType::Object).
sourcepub fn with_type(schema_type: SchemaType) -> Self
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);sourcepub fn schema_type(self, schema_type: SchemaType) -> Self
pub fn schema_type(self, schema_type: SchemaType) -> Self
Add or change type of the object e.g SchemaType::String.
sourcepub fn format(self, format: SchemaFormat) -> Self
pub fn format(self, format: SchemaFormat) -> Self
Add or change additional format for detailing the schema type.
sourcepub fn property<S: Into<String>, I: Into<RefOr<Schema>>>(
self,
property_name: S,
component: I
) -> Self
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.
sourcepub fn additional_properties<I: Into<AdditionalProperties<Schema>>>(
self,
additional_properties: I
) -> Self
pub fn additional_properties<I: Into<AdditionalProperties<Schema>>>( self, additional_properties: I ) -> Self
Add additional properties to the Object.
sourcepub fn required(self, required_field: impl Into<String>) -> Self
pub fn required(self, required_field: impl Into<String>) -> Self
Add field to the required fields of Object.
sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Add or change description of the property. Markdown syntax is supported.
sourcepub fn default_value(self, default: Value) -> Self
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.
sourcepub fn deprecated(self, deprecated: Deprecated) -> Self
pub fn deprecated(self, deprecated: Deprecated) -> Self
Add or change deprecated status for Object.
sourcepub fn enum_values<I, E>(self, enum_values: I) -> Selfwhere
I: IntoIterator<Item = E>,
E: Into<Value>,
pub fn enum_values<I, E>(self, enum_values: I) -> Selfwhere I: IntoIterator<Item = E>, E: Into<Value>,
Add or change enum property variants.
sourcepub fn example(self, example: Value) -> Self
pub fn example(self, example: Value) -> Self
Add or change example shown in UI of the value for richer documentation.
sourcepub fn write_only(self, write_only: bool) -> Self
pub fn write_only(self, write_only: bool) -> Self
Add or change write only flag for Object.
sourcepub fn multiple_of(self, multiple_of: f64) -> Self
pub fn multiple_of(self, multiple_of: f64) -> Self
Set or change multiple_of validation flag for number and integer type values.
sourcepub fn maximum(self, maximum: f64) -> Self
pub fn maximum(self, maximum: f64) -> Self
Set or change inclusive maximum value for number and integer values.
sourcepub fn minimum(self, minimum: f64) -> Self
pub fn minimum(self, minimum: f64) -> Self
Set or change inclusive minimum value for number and integer values.
sourcepub fn exclusive_maximum(self, exclusive_maximum: f64) -> Self
pub fn exclusive_maximum(self, exclusive_maximum: f64) -> Self
Set or change exclusive maximum value for number and integer values.
sourcepub fn exclusive_minimum(self, exclusive_minimum: f64) -> Self
pub fn exclusive_minimum(self, exclusive_minimum: f64) -> Self
Set or change exclusive minimum value for number and integer values.
sourcepub fn max_length(self, max_length: usize) -> Self
pub fn max_length(self, max_length: usize) -> Self
Set or change maximum length for string values.
sourcepub fn min_length(self, min_length: usize) -> Self
pub fn min_length(self, min_length: usize) -> Self
Set or change minimum length for string values.
sourcepub fn pattern<I: Into<String>>(self, pattern: I) -> Self
pub fn pattern<I: Into<String>>(self, pattern: I) -> Self
Set or change a valid regular expression for string value to match.
sourcepub fn max_properties(self, max_properties: usize) -> Self
pub fn max_properties(self, max_properties: usize) -> Self
Set or change maximum number of properties the Object can hold.
sourcepub fn min_properties(self, min_properties: usize) -> Self
pub fn min_properties(self, min_properties: usize) -> Self
Set or change minimum number of properties the Object can hold.