Skip to main content

JsonSchema

Trait JsonSchema 

Source
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§

Source

fn schema() -> Schema

Generate the JSON Schema for this type.

Provided Methods§

Source

fn schema_name() -> Option<&'static str>

Get the schema name for use in #/components/schemas/.

Source

fn schema_with_registry(registry: &SchemaRegistry) -> Schema
where 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.

Implementations on Foreign Types§

Source§

impl JsonSchema for &str

Source§

impl JsonSchema for bool

Source§

impl JsonSchema for f32

Source§

impl JsonSchema for f64

Source§

impl JsonSchema for i8

Source§

impl JsonSchema for i16

Source§

impl JsonSchema for i32

Source§

impl JsonSchema for i64

Source§

impl JsonSchema for i128

Source§

impl JsonSchema for isize

Source§

impl JsonSchema for u8

Source§

impl JsonSchema for u16

Source§

impl JsonSchema for u32

Source§

impl JsonSchema for u64

Source§

impl JsonSchema for u128

Source§

impl JsonSchema for usize

Source§

impl JsonSchema for String

Source§

impl JsonSchema for NonZeroI8

Source§

impl JsonSchema for NonZeroI16

Source§

impl JsonSchema for NonZeroI32

Source§

impl JsonSchema for NonZeroI64

Source§

impl JsonSchema for NonZeroI128

Source§

impl JsonSchema for NonZeroIsize

Source§

impl JsonSchema for NonZeroU8

Source§

impl JsonSchema for NonZeroU16

Source§

impl JsonSchema for NonZeroU32

Source§

impl JsonSchema for NonZeroU64

Source§

impl JsonSchema for NonZeroU128

Source§

impl JsonSchema for NonZeroUsize

Source§

impl<T: JsonSchema> JsonSchema for Option<T>

Source§

impl<T: JsonSchema> JsonSchema for Vec<T>

Implementors§