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>) -> Self
pub fn new(title: impl Into<String>, description: impl Into<String>) -> Self
Create a new schema with basic metadata
Sourcepub fn with_property(
self,
name: impl Into<String>,
property: SchemaProperty,
) -> Self
pub fn with_property( self, name: impl Into<String>, property: SchemaProperty, ) -> Self
Add a property to this schema
Sourcepub fn with_required(self, name: impl Into<String>) -> Self
pub fn with_required(self, name: impl Into<String>) -> Self
Mark a property as required
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
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<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 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