pub struct Schema {
pub schema_version: Option<String>,
pub title: Option<String>,
pub description: Option<String>,
pub schema_type: Option<Value>,
pub properties: Option<HashMap<String, SchemaProperty>>,
pub required: Option<Vec<String>>,
pub one_of: Option<Vec<Schema>>,
pub defs: Option<HashMap<String, Value>>,
pub additional: HashMap<String, Value>,
}Expand description
A complete JSON Schema with metadata
Fields§
§schema_version: Option<String>The JSON Schema specification version
title: Option<String>Title of the schema
description: Option<String>Description of what this schema represents
schema_type: Option<Value>The schema type (typically “object” for root, can be string or array)
properties: Option<HashMap<String, SchemaProperty>>Properties for object types
required: Option<Vec<String>>Required properties
one_of: Option<Vec<Schema>>Enum variants (for discriminated unions)
defs: Option<HashMap<String, Value>>Schema definitions (for $defs or definitions)
additional: HashMap<String, Value>Any additional schema properties
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn new(title: impl Into<String>, description: impl Into<String>) -> Schema
pub fn new(title: impl Into<String>, description: impl Into<String>) -> Schema
Create a new schema with basic metadata
Sourcepub fn with_property(
self,
name: impl Into<String>,
property: SchemaProperty,
) -> Schema
pub fn with_property( self, name: impl Into<String>, property: SchemaProperty, ) -> Schema
Add a property to this schema
Sourcepub fn with_required(self, name: impl Into<String>) -> Schema
pub fn with_required(self, name: impl Into<String>) -> Schema
Mark a property as required
Sourcepub fn with_description(self, description: impl Into<String>) -> Schema
pub fn with_description(self, description: impl Into<String>) -> Schema
Set the description
Sourcepub fn get_method_schema(&self, method_name: &str) -> Option<Schema>
pub fn get_method_schema(&self, method_name: &str) -> Option<Schema>
Extract a single method’s schema from the oneOf array
Searches the oneOf variants for a method matching the given name. Returns the variant schema if found, None otherwise.
Sourcepub fn list_methods(&self) -> Vec<String>
pub fn list_methods(&self) -> Vec<String>
List all method names from the oneOf array
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Schema
impl<'de> Deserialize<'de> for Schema
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Schema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Schema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Schema
impl Serialize for Schema
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. 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 UnsafeUnpin 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: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more