pub struct JsonSchema {Show 34 fields
pub schema: Option<String>,
pub id: Option<String>,
pub title: Option<String>,
pub description: Option<String>,
pub schema_type: Option<JsonSchemaType>,
pub format: Option<String>,
pub properties: Option<HashMap<String, JsonSchema>>,
pub required: Option<Vec<String>>,
pub items: Option<Box<JsonSchema>>,
pub additional_properties: Option<AdditionalProperties>,
pub min_length: Option<usize>,
pub max_length: Option<usize>,
pub pattern: Option<String>,
pub minimum: Option<f64>,
pub maximum: Option<f64>,
pub exclusive_minimum: Option<f64>,
pub exclusive_maximum: Option<f64>,
pub multiple_of: Option<f64>,
pub min_items: Option<usize>,
pub max_items: Option<usize>,
pub unique_items: Option<bool>,
pub enum: Option<Vec<Value>>,
pub const: Option<Value>,
pub reference: Option<String>,
pub any_of: Option<Vec<JsonSchema>>,
pub all_of: Option<Vec<JsonSchema>>,
pub one_of: Option<Vec<JsonSchema>>,
pub not: Option<Box<JsonSchema>>,
pub default: Option<Value>,
pub examples: Option<Vec<Value>>,
pub deprecated: Option<bool>,
pub read_only: Option<bool>,
pub write_only: Option<bool>,
pub defs: Option<HashMap<String, JsonSchema>>,
}Expand description
JSON Schema document (Draft 2020-12)
Fields§
§schema: Option<String>§id: Option<String>§title: Option<String>§description: Option<String>§schema_type: Option<JsonSchemaType>§format: Option<String>§properties: Option<HashMap<String, JsonSchema>>§required: Option<Vec<String>>§items: Option<Box<JsonSchema>>§additional_properties: Option<AdditionalProperties>§min_length: Option<usize>§max_length: Option<usize>§pattern: Option<String>§minimum: Option<f64>§maximum: Option<f64>§exclusive_minimum: Option<f64>§exclusive_maximum: Option<f64>§multiple_of: Option<f64>§min_items: Option<usize>§max_items: Option<usize>§unique_items: Option<bool>§enum: Option<Vec<Value>>§const: Option<Value>§reference: Option<String>§any_of: Option<Vec<JsonSchema>>§all_of: Option<Vec<JsonSchema>>§one_of: Option<Vec<JsonSchema>>§not: Option<Box<JsonSchema>>§default: Option<Value>§examples: Option<Vec<Value>>§deprecated: Option<bool>§read_only: Option<bool>§write_only: Option<bool>§defs: Option<HashMap<String, JsonSchema>>Implementations§
Source§impl JsonSchema
impl JsonSchema
Sourcepub fn array(items: JsonSchema) -> Self
pub fn array(items: JsonSchema) -> Self
Create an array schema
Sourcepub fn description(self, desc: impl Into<String>) -> Self
pub fn description(self, desc: impl Into<String>) -> Self
Set the description
Sourcepub fn property(self, name: impl Into<String>, schema: JsonSchema) -> Self
pub fn property(self, name: impl Into<String>, schema: JsonSchema) -> Self
Add a property to an object schema
Sourcepub fn min_length(self, min: usize) -> Self
pub fn min_length(self, min: usize) -> Self
Set minimum length for strings
Sourcepub fn max_length(self, max: usize) -> Self
pub fn max_length(self, max: usize) -> Self
Set maximum length for strings
Sourcepub fn exclusive_minimum(self, min: impl Into<f64>) -> Self
pub fn exclusive_minimum(self, min: impl Into<f64>) -> Self
Set exclusive minimum for numbers
Sourcepub fn exclusive_maximum(self, max: impl Into<f64>) -> Self
pub fn exclusive_maximum(self, max: impl Into<f64>) -> Self
Set exclusive maximum for numbers
Sourcepub fn multiple_of(self, divisor: impl Into<f64>) -> Self
pub fn multiple_of(self, divisor: impl Into<f64>) -> Self
Set multipleOf constraint for numbers
Sourcepub fn unique_items(self, unique: bool) -> Self
pub fn unique_items(self, unique: bool) -> Self
Set unique items constraint for arrays
Sourcepub fn enum_values<T: Serialize>(self, values: &[T]) -> Self
pub fn enum_values<T: Serialize>(self, values: &[T]) -> Self
Set enum values
Sourcepub fn const_value<T: Serialize>(self, value: T) -> Self
pub fn const_value<T: Serialize>(self, value: T) -> Self
Set a const value
Sourcepub fn deprecated(self, deprecated: bool) -> Self
pub fn deprecated(self, deprecated: bool) -> Self
Mark as deprecated
Sourcepub fn write_only(self, write_only: bool) -> Self
pub fn write_only(self, write_only: bool) -> Self
Mark as write-only
Sourcepub fn any_of(schemas: Vec<JsonSchema>) -> Self
pub fn any_of(schemas: Vec<JsonSchema>) -> Self
Create an anyOf schema
Sourcepub fn all_of(schemas: Vec<JsonSchema>) -> Self
pub fn all_of(schemas: Vec<JsonSchema>) -> Self
Create an allOf schema
Sourcepub fn one_of(schemas: Vec<JsonSchema>) -> Self
pub fn one_of(schemas: Vec<JsonSchema>) -> Self
Create a oneOf schema
Sourcepub fn negation(schema: JsonSchema) -> Self
pub fn negation(schema: JsonSchema) -> Self
Create a negation schema (not)
Trait Implementations§
Source§impl Clone for JsonSchema
impl Clone for JsonSchema
Source§fn clone(&self) -> JsonSchema
fn clone(&self) -> JsonSchema
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for JsonSchema
impl Debug for JsonSchema
Source§impl Default for JsonSchema
impl Default for JsonSchema
Source§impl<'de> Deserialize<'de> for JsonSchema
impl<'de> Deserialize<'de> for JsonSchema
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for JsonSchema
impl RefUnwindSafe for JsonSchema
impl Send for JsonSchema
impl Sync for JsonSchema
impl Unpin for JsonSchema
impl UnwindSafe for JsonSchema
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
Mutably borrows from an owned value. Read more