pub enum Schema {
Boolean(bool),
Ref(RefSchema),
Object(ObjectSchema),
Array(ArraySchema),
Primitive(PrimitiveSchema),
Enum(EnumSchema),
}Expand description
JSON Schema representation.
Variants§
Boolean(bool)
Boolean schema (true = any, false = none).
Ref(RefSchema)
Reference to another schema.
Object(ObjectSchema)
Object schema.
Array(ArraySchema)
Array schema.
Primitive(PrimitiveSchema)
Primitive type schema.
Enum(EnumSchema)
Enum/union schema (oneOf, anyOf, allOf).
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn object(
properties: HashMap<String, Schema>,
required: Vec<String>,
) -> Self
pub fn object( properties: HashMap<String, Schema>, required: Vec<String>, ) -> Self
Create an object schema with the given properties.
Sourcepub fn with_title(self, title: impl Into<String>) -> Self
pub fn with_title(self, title: impl Into<String>) -> Self
Set title on this schema (if object).
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set description on this schema (if object).
Sourcepub fn one_of(schemas: Vec<Schema>) -> Self
pub fn one_of(schemas: Vec<Schema>) -> Self
Create a oneOf schema (discriminated union - exactly one must match).
Sourcepub fn any_of(schemas: Vec<Schema>) -> Self
pub fn any_of(schemas: Vec<Schema>) -> Self
Create an anyOf schema (untagged union - at least one must match).
Sourcepub fn all_of(schemas: Vec<Schema>) -> Self
pub fn all_of(schemas: Vec<Schema>) -> Self
Create an allOf schema (intersection - all must match).
Sourcepub fn string_enum(values: Vec<String>) -> Self
pub fn string_enum(values: Vec<String>) -> Self
Create a string enum schema (for unit variants only).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Schema
impl<'de> Deserialize<'de> for Schema
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 Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnwindSafe for Schema
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).