SchemaObject

Struct SchemaObject 

Source
pub struct SchemaObject {
Show 13 fields pub schema_type: Option<String>, 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("string".to_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("object".to_string()),
    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<String>

Schema type

The JSON Schema type: “object”, “array”, “string”, “number”, “integer”, “boolean”, “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

Source§

fn clone(&self) -> SchemaObject

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SchemaObject

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SchemaObject

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<SchemaObject, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SchemaObject

Source§

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,