#[non_exhaustive]pub struct Object {Show 27 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: Vec<Value>,
pub required: IndexSet<String>,
pub properties: PropMap<String, RefOr<Schema>>,
pub additional_properties: Option<Box<AdditionalProperties<Schema>>>,
pub deprecated: Option<Deprecated>,
pub examples: Vec<Value>,
pub write_only: Option<bool>,
pub read_only: Option<bool>,
pub xml: Option<Xml>,
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>,
pub extensions: PropMap<String, Value>,
pub content_encoding: String,
pub content_media_type: String,
}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. BasicType::Object for object and BasicType::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: 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 PropMap 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.
examples: Vec<Value>Examples 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>§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.
extensions: PropMap<String, Value>Optional extensions x-something.
content_encoding: StringThe content_encoding keyword specifies the encoding used to store the contents, as specified in
RFC 2054, part 6.1 and [RFC 4648](RFC 2054, part 6.1).
Typically this is either unset for string content types which then uses the content
encoding of the underlying JSON document. If the content is in binary format such as an image or an audio
set it to base64 to encode it as Base64.
See more details at https://json-schema.org/understanding-json-schema/reference/non_json_data#contentencoding
content_media_type: StringThe content_media_type keyword specifies the MIME type of the contents of a string,
as described in RFC 2046.
See more details at https://json-schema.org/understanding-json-schema/reference/non_json_data#contentmediatype
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<T: Into<SchemaType>>(schema_type: T) -> Self
pub fn with_type<T: Into<SchemaType>>(schema_type: T) -> 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(BasicType::String);Sourcepub fn schema_type<T: Into<SchemaType>>(self, schema_type: T) -> Self
pub fn schema_type<T: Into<SchemaType>>(self, schema_type: T) -> Self
Add or change type of the object e.g. to change type to string
use value SchemaType::Type(Type::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) -> Self
pub fn enum_values<I, E>(self, enum_values: I) -> Self
Add or change enum property variants.
Sourcepub fn example<V: Into<Value>>(self, example: V) -> Self
pub fn example<V: Into<Value>>(self, example: V) -> Self
Add or change example shown in UI of the value for richer documentation.
Sourcepub fn examples<I: IntoIterator<Item = V>, V: Into<Value>>(
self,
examples: I,
) -> Self
pub fn examples<I: IntoIterator<Item = V>, V: Into<Value>>( self, examples: I, ) -> Self
Add or change examples 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.
Sourcepub fn add_extension<K: Into<String>>(self, key: K, value: Value) -> Self
pub fn add_extension<K: Into<String>>(self, key: K, value: Value) -> Self
Add openapi extension (x-something) for Object.
Sourcepub fn content_encoding<S: Into<String>>(self, content_encoding: S) -> Self
pub fn content_encoding<S: Into<String>>(self, content_encoding: S) -> Self
Set of change Object::content_encoding. Typically left empty but could be base64 for
example.
Sourcepub fn content_media_type<S: Into<String>>(self, content_media_type: S) -> Self
pub fn content_media_type<S: Into<String>>(self, content_media_type: S) -> Self
Set of change Object::content_media_type. Value must be valid MIME type e.g.
application/json.