pub enum JsonSchema {
String {
description: Option<String>,
pattern: Option<String>,
min_length: Option<u64>,
max_length: Option<u64>,
enum_values: Option<Vec<String>>,
},
Number {
description: Option<String>,
minimum: Option<f64>,
maximum: Option<f64>,
},
Integer {
description: Option<String>,
minimum: Option<i64>,
maximum: Option<i64>,
},
Boolean {
description: Option<String>,
},
Array {
description: Option<String>,
items: Option<Box<JsonSchema>>,
min_items: Option<u64>,
max_items: Option<u64>,
},
Object {
description: Option<String>,
properties: Option<HashMap<String, JsonSchema>>,
required: Option<Vec<String>>,
additional_properties: Option<bool>,
},
}Expand description
Core MCP protocol types, errors, and specification compliance A JSON Schema definition
Variants§
String
String type
Fields
Number
Number type
Integer
Integer type
Boolean
Boolean type
Array
Array type
Fields
items: Option<Box<JsonSchema>>Object
Object type
Implementations§
Source§impl JsonSchema
impl JsonSchema
Sourcepub fn string() -> JsonSchema
pub fn string() -> JsonSchema
Create a string schema
Sourcepub fn string_with_description(description: impl Into<String>) -> JsonSchema
pub fn string_with_description(description: impl Into<String>) -> JsonSchema
Create a string schema with description
Sourcepub fn string_enum(values: Vec<String>) -> JsonSchema
pub fn string_enum(values: Vec<String>) -> JsonSchema
Create a string enum schema
Sourcepub fn number() -> JsonSchema
pub fn number() -> JsonSchema
Create a number schema
Sourcepub fn number_with_description(description: impl Into<String>) -> JsonSchema
pub fn number_with_description(description: impl Into<String>) -> JsonSchema
Create a number schema with description
Sourcepub fn integer() -> JsonSchema
pub fn integer() -> JsonSchema
Create an integer schema
Sourcepub fn integer_with_description(description: impl Into<String>) -> JsonSchema
pub fn integer_with_description(description: impl Into<String>) -> JsonSchema
Create an integer schema with description
Sourcepub fn boolean() -> JsonSchema
pub fn boolean() -> JsonSchema
Create a boolean schema
Sourcepub fn boolean_with_description(description: impl Into<String>) -> JsonSchema
pub fn boolean_with_description(description: impl Into<String>) -> JsonSchema
Create a boolean schema with description
Sourcepub fn array(items: JsonSchema) -> JsonSchema
pub fn array(items: JsonSchema) -> JsonSchema
Create an array schema
Sourcepub fn array_with_description(
items: JsonSchema,
description: impl Into<String>,
) -> JsonSchema
pub fn array_with_description( items: JsonSchema, description: impl Into<String>, ) -> JsonSchema
Create an array schema with description
Sourcepub fn object() -> JsonSchema
pub fn object() -> JsonSchema
Create an object schema
Sourcepub fn object_with_properties(
properties: HashMap<String, JsonSchema>,
) -> JsonSchema
pub fn object_with_properties( properties: HashMap<String, JsonSchema>, ) -> JsonSchema
Create an object schema with properties
Sourcepub fn object_with_required(
properties: HashMap<String, JsonSchema>,
required: Vec<String>,
) -> JsonSchema
pub fn object_with_required( properties: HashMap<String, JsonSchema>, required: Vec<String>, ) -> JsonSchema
Create an object schema with properties and required fields
Sourcepub fn with_description(self, description: impl Into<String>) -> JsonSchema
pub fn with_description(self, description: impl Into<String>) -> JsonSchema
Add description to any schema
Sourcepub fn with_minimum(self, minimum: f64) -> JsonSchema
pub fn with_minimum(self, minimum: f64) -> JsonSchema
Add minimum constraint to number schema
Sourcepub fn with_maximum(self, maximum: f64) -> JsonSchema
pub fn with_maximum(self, maximum: f64) -> JsonSchema
Add maximum constraint to number schema
Sourcepub fn with_properties(
self,
properties: HashMap<String, JsonSchema>,
) -> JsonSchema
pub fn with_properties( self, properties: HashMap<String, JsonSchema>, ) -> JsonSchema
Add properties to object schema
Sourcepub fn with_required(self, required: Vec<String>) -> JsonSchema
pub fn with_required(self, required: Vec<String>) -> JsonSchema
Add required fields to object schema
Trait Implementations§
Source§impl Clone for JsonSchema
impl Clone for JsonSchema
Source§fn clone(&self) -> JsonSchema
fn clone(&self) -> JsonSchema
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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<JsonSchema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<JsonSchema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for JsonSchema
impl Serialize for JsonSchema
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,
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
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>
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>
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