pub trait JsonSchema {
// Required method
fn schema() -> Schema;
// Provided methods
fn schema_name() -> Option<&'static str> { ... }
fn schema_with_registry(registry: &SchemaRegistry) -> Schema
where Self: Sized { ... }
}Expand description
Trait for types that can generate JSON Schema.
Required Methods§
Provided Methods§
Sourcefn schema_name() -> Option<&'static str>
fn schema_name() -> Option<&'static str>
Get the schema name for use in #/components/schemas/.
Sourcefn schema_with_registry(registry: &SchemaRegistry) -> Schemawhere
Self: Sized,
fn schema_with_registry(registry: &SchemaRegistry) -> Schemawhere
Self: Sized,
Get the schema for this type, registering it with the given registry.
If the type has a schema name, this registers the full schema definition
and returns a $ref reference. Otherwise, returns the inline schema.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.