pub enum Schema {
Reference {
reference: String,
},
Object(Box<SchemaObject>),
}Expand description
JSON Schema object
Flexible representation that can hold any valid JSON Schema. This type supports
both schema references (using $ref) and complete inline schema definitions.
Schemas define the structure and validation rules for message payloads, following the JSON Schema specification.
§Example
§Reference Schema
use asyncapi_rust_models::Schema;
let schema = Schema::Reference {
reference: "#/components/schemas/ChatMessage".to_string(),
};§Object Schema
use asyncapi_rust_models::{Schema, SchemaObject};
use std::collections::HashMap;
let schema = Schema::Object(Box::new(SchemaObject {
schema_type: Some(serde_json::json!("object")),
properties: None,
required: Some(vec!["username".to_string(), "room".to_string()]),
description: Some("A chat message".to_string()),
title: Some("ChatMessage".to_string()),
enum_values: None,
const_value: None,
items: None,
additional_properties: None,
one_of: None,
any_of: None,
all_of: None,
additional: HashMap::new(),
}));Variants§
Reference
Reference to another schema ($ref)
Points to a reusable schema definition in the components section. Format: “#/components/schemas/{schemaName}”
Object(Box<SchemaObject>)
Full schema object (boxed to reduce enum size)
Contains a complete JSON Schema definition with all properties inline
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 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