#[non_exhaustive]pub struct Schema {Show 25 fields
pub type: Type,
pub format: String,
pub title: String,
pub description: String,
pub nullable: bool,
pub default: Option<Value>,
pub items: Option<Box<Schema>>,
pub min_items: i64,
pub max_items: i64,
pub enum: Vec<String>,
pub properties: HashMap<String, Schema>,
pub property_ordering: Vec<String>,
pub required: Vec<String>,
pub min_properties: i64,
pub max_properties: i64,
pub minimum: f64,
pub maximum: f64,
pub min_length: i64,
pub max_length: i64,
pub pattern: String,
pub example: Option<Value>,
pub any_of: Vec<Schema>,
pub additional_properties: Option<Value>,
pub ref: String,
pub defs: HashMap<String, Schema>,
/* private fields */
}Expand description
Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed.
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.type: TypeOptional. The type of the data.
format: StringOptional. The format of the data. Supported formats: for NUMBER type: “float”, “double” for INTEGER type: “int32”, “int64” for STRING type: “email”, “byte”, etc
title: StringOptional. The title of the Schema.
description: StringOptional. The description of the data.
nullable: boolOptional. Indicates if the value may be null.
default: Option<Value>Optional. Default value of the data.
items: Option<Box<Schema>>Optional. SCHEMA FIELDS FOR TYPE ARRAY Schema of the elements of Type.ARRAY.
min_items: i64Optional. Minimum number of the elements for Type.ARRAY.
max_items: i64Optional. Maximum number of the elements for Type.ARRAY.
enum: Vec<String>Optional. Possible values of the element of primitive type with enum format. Examples:
. We can define direction as : {type:STRING, format:enum, enum:[“EAST”, NORTH“, “SOUTH”, “WEST”]} . We can define apartment number as : {type:INTEGER, format:enum, enum:[“101”, “201”, “301”]}
properties: HashMap<String, Schema>Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of Type.OBJECT.
property_ordering: Vec<String>Optional. The order of the properties. Not a standard field in open api spec. Only used to support the order of the properties.
required: Vec<String>Optional. Required properties of Type.OBJECT.
min_properties: i64Optional. Minimum number of the properties for Type.OBJECT.
max_properties: i64Optional. Maximum number of the properties for Type.OBJECT.
minimum: f64Optional. SCHEMA FIELDS FOR TYPE INTEGER and NUMBER Minimum value of the Type.INTEGER and Type.NUMBER
maximum: f64Optional. Maximum value of the Type.INTEGER and Type.NUMBER
min_length: i64Optional. SCHEMA FIELDS FOR TYPE STRING Minimum length of the Type.STRING
max_length: i64Optional. Maximum length of the Type.STRING
pattern: StringOptional. Pattern of the Type.STRING to restrict a string to a regular expression.
example: Option<Value>Optional. Example of the object. Will only populated when the object is the root.
any_of: Vec<Schema>Optional. The value should be validated against any (one or more) of the subschemas in the list.
additional_properties: Option<Value>Optional. Can either be a boolean or an object; controls the presence of additional properties.
ref: StringOptional. Allows indirect references between schema nodes. The value should
be a valid reference to a child of the root defs.
For example, the following schema defines a reference to a schema node named “Pet”:
type: object properties: pet: ref: #/defs/Pet defs: Pet: type: object properties: name: type: string
The value of the “pet” property is a reference to the schema node named “Pet”. See details in https://json-schema.org/understanding-json-schema/structuring
defs: HashMap<String, Schema>Optional. A map of definitions for use by ref
Only allowed at the root of the schema.
Implementations§
Source§impl Schema
impl Schema
pub fn new() -> Self
Sourcepub fn set_format<T: Into<String>>(self, v: T) -> Self
pub fn set_format<T: Into<String>>(self, v: T) -> Self
Sets the value of format.
Sourcepub fn set_description<T: Into<String>>(self, v: T) -> Self
pub fn set_description<T: Into<String>>(self, v: T) -> Self
Sets the value of description.
Sourcepub fn set_nullable<T: Into<bool>>(self, v: T) -> Self
pub fn set_nullable<T: Into<bool>>(self, v: T) -> Self
Sets the value of nullable.
Sourcepub fn set_min_items<T: Into<i64>>(self, v: T) -> Self
pub fn set_min_items<T: Into<i64>>(self, v: T) -> Self
Sets the value of min_items.
Sourcepub fn set_max_items<T: Into<i64>>(self, v: T) -> Self
pub fn set_max_items<T: Into<i64>>(self, v: T) -> Self
Sets the value of max_items.
Sourcepub fn set_properties<T, K, V>(self, v: T) -> Self
pub fn set_properties<T, K, V>(self, v: T) -> Self
Sets the value of properties.
Sourcepub fn set_property_ordering<T, V>(self, v: T) -> Self
pub fn set_property_ordering<T, V>(self, v: T) -> Self
Sets the value of property_ordering.
Sourcepub fn set_required<T, V>(self, v: T) -> Self
pub fn set_required<T, V>(self, v: T) -> Self
Sets the value of required.
Sourcepub fn set_min_properties<T: Into<i64>>(self, v: T) -> Self
pub fn set_min_properties<T: Into<i64>>(self, v: T) -> Self
Sets the value of min_properties.
Sourcepub fn set_max_properties<T: Into<i64>>(self, v: T) -> Self
pub fn set_max_properties<T: Into<i64>>(self, v: T) -> Self
Sets the value of max_properties.
Sourcepub fn set_minimum<T: Into<f64>>(self, v: T) -> Self
pub fn set_minimum<T: Into<f64>>(self, v: T) -> Self
Sets the value of minimum.
Sourcepub fn set_maximum<T: Into<f64>>(self, v: T) -> Self
pub fn set_maximum<T: Into<f64>>(self, v: T) -> Self
Sets the value of maximum.
Sourcepub fn set_min_length<T: Into<i64>>(self, v: T) -> Self
pub fn set_min_length<T: Into<i64>>(self, v: T) -> Self
Sets the value of min_length.
Sourcepub fn set_max_length<T: Into<i64>>(self, v: T) -> Self
pub fn set_max_length<T: Into<i64>>(self, v: T) -> Self
Sets the value of max_length.
Sourcepub fn set_pattern<T: Into<String>>(self, v: T) -> Self
pub fn set_pattern<T: Into<String>>(self, v: T) -> Self
Sets the value of pattern.
Sourcepub fn set_any_of<T, V>(self, v: T) -> Self
pub fn set_any_of<T, V>(self, v: T) -> Self
Sets the value of any_of.
Sourcepub fn set_additional_properties<T: Into<Option<Value>>>(self, v: T) -> Self
pub fn set_additional_properties<T: Into<Option<Value>>>(self, v: T) -> Self
Sets the value of additional_properties.