pub struct SchemaObject {Show 13 fields
pub schema_type: Option<Value>,
pub properties: Option<HashMap<String, Box<Schema>>>,
pub required: Option<Vec<String>>,
pub description: Option<String>,
pub title: Option<String>,
pub enum_values: Option<Vec<Value>>,
pub const_value: Option<Value>,
pub items: Option<Box<Schema>>,
pub additional_properties: Option<Box<Schema>>,
pub one_of: Option<Vec<Schema>>,
pub any_of: Option<Vec<Schema>>,
pub all_of: Option<Vec<Schema>>,
pub additional: HashMap<String, Value>,
}Expand description
Schema object with all JSON Schema properties
Complete representation of a JSON Schema with support for all standard properties. This struct provides fine-grained control over schema definitions for message payloads.
§Example
use asyncapi_rust_models::{Schema, SchemaObject};
use std::collections::HashMap;
// String property schema
let username_schema = Schema::Object(Box::new(SchemaObject {
schema_type: Some(serde_json::json!("string")),
properties: None,
required: None,
description: Some("User's display name".to_string()),
title: None,
enum_values: None,
const_value: None,
items: None,
additional_properties: None,
one_of: None,
any_of: None,
all_of: None,
additional: HashMap::new(),
}));
// Object schema with properties
let mut properties = HashMap::new();
properties.insert("username".to_string(), Box::new(username_schema));
let message_schema = SchemaObject {
schema_type: Some(serde_json::json!("object")),
properties: Some(properties),
required: Some(vec!["username".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(),
};Fields§
§schema_type: Option<Value>Schema type
The JSON Schema type: “object”, “array”, “string”, “number”, “integer”, “boolean”, “null” Can also be an array of types for schemas that allow multiple types (e.g., [“string”, “null”])
properties: Option<HashMap<String, Box<Schema>>>Properties (for object type)
Map of property names to their schemas when schema_type is “object”
required: Option<Vec<String>>Required properties
List of property names that must be present (for object types)
description: Option<String>Description
Human-readable description of what this schema represents
title: Option<String>Title
A short title for the schema
enum_values: Option<Vec<Value>>Enum values
List of allowed values (for enum types)
const_value: Option<Value>Const value
A single constant value that this schema must match
items: Option<Box<Schema>>Items schema (for array type)
Schema for array elements when schema_type is “array”
additional_properties: Option<Box<Schema>>Additional properties
Schema for additional properties not explicitly defined (for object types)
one_of: Option<Vec<Schema>>OneOf schemas
Value must match exactly one of these schemas (XOR logic)
any_of: Option<Vec<Schema>>AnyOf schemas
Value must match at least one of these schemas (OR logic)
all_of: Option<Vec<Schema>>AllOf schemas
Value must match all of these schemas (AND logic)
additional: HashMap<String, Value>Additional fields that may be present in the schema
Captures any additional JSON Schema properties not explicitly defined above
Trait Implementations§
Source§impl Clone for SchemaObject
impl Clone for SchemaObject
Source§fn clone(&self) -> SchemaObject
fn clone(&self) -> SchemaObject
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more