#[non_exhaustive]pub struct Object {Show 25 fields
pub schema_type: SchemaType,
pub title: 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 Schema
s 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: SchemaType
Type of Object
e.g. SchemaType::Object
for object
and SchemaType::String
for
string
types.
title: Option<String>
Changes the Object
title.
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: 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
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);
Trait Implementations§
source§impl<'de> Deserialize<'de> for Object
impl<'de> Deserialize<'de> for Object
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl From<Object> for ObjectBuilder
impl From<Object> for ObjectBuilder
source§impl From<ObjectBuilder> for Object
impl From<ObjectBuilder> for Object
source§fn from(value: ObjectBuilder) -> Self
fn from(value: ObjectBuilder) -> Self
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)