pub struct JsonSchema {Show 19 fields
pub schema: String,
pub id: Option<String>,
pub title: Option<String>,
pub description: Option<String>,
pub schema_type: String,
pub properties: Option<HashMap<String, JsonSchema>>,
pub required: Option<Vec<String>>,
pub items: Option<Box<JsonSchema>>,
pub enum_values: Option<Vec<Value>>,
pub additional_properties: Option<Box<JsonSchema>>,
pub definitions: Option<HashMap<String, JsonSchema>>,
pub minimum: Option<f64>,
pub maximum: Option<f64>,
pub pattern: Option<String>,
pub format: Option<String>,
pub one_of: Option<Vec<JsonSchema>>,
pub any_of: Option<Vec<JsonSchema>>,
pub all_of: Option<Vec<JsonSchema>>,
pub reference: Option<String>,
}Expand description
JSON Schema document
Fields§
§schema: StringSchema version (always “https://json-schema.org/draft/2020-12/schema”)
id: Option<String>Schema identifier
title: Option<String>Schema title
description: Option<String>Schema description
schema_type: StringType of the schema
properties: Option<HashMap<String, JsonSchema>>Properties for object types
required: Option<Vec<String>>Required property names
items: Option<Box<JsonSchema>>Items schema for array types
enum_values: Option<Vec<Value>>Enum values for enums
additional_properties: Option<Box<JsonSchema>>Additional properties
definitions: Option<HashMap<String, JsonSchema>>Schema definitions
minimum: Option<f64>Minimum value for numbers
maximum: Option<f64>Maximum value for numbers
pattern: Option<String>Pattern for strings
format: Option<String>Format for strings
one_of: Option<Vec<JsonSchema>>One of (union types)
any_of: Option<Vec<JsonSchema>>Any of (union types with overlap)
all_of: Option<Vec<JsonSchema>>All of (intersection types)
reference: Option<String>Reference to another schema
Implementations§
Source§impl JsonSchema
impl JsonSchema
Sourcepub fn array(items: JsonSchema) -> Self
pub fn array(items: JsonSchema) -> Self
Create an array schema
Sourcepub fn with_title(self, title: String) -> Self
pub fn with_title(self, title: String) -> Self
Set title
Sourcepub fn with_description(self, description: String) -> Self
pub fn with_description(self, description: String) -> Self
Set description
Sourcepub fn add_property(&mut self, name: String, schema: JsonSchema)
pub fn add_property(&mut self, name: String, schema: JsonSchema)
Add a property to an object schema
Sourcepub fn add_required(&mut self, name: String)
pub fn add_required(&mut self, name: String)
Add a required property
Sourcepub fn with_pattern(self, pattern: String) -> Self
pub fn with_pattern(self, pattern: String) -> Self
Set pattern for strings
Sourcepub fn with_format(self, format: String) -> Self
pub fn with_format(self, format: String) -> Self
Set format for strings
Sourcepub fn add_definition(&mut self, name: String, schema: JsonSchema)
pub fn add_definition(&mut self, name: String, schema: JsonSchema)
Add a definition
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<'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