[][src]Trait rocket_okapi::JsonSchema

pub trait JsonSchema {
    fn schema_name() -> String;
fn json_schema(gen: &mut SchemaGenerator) -> Schema; fn is_referenceable() -> bool { ... } }

A type which can be described as a JSON Schema document.

This is implemented for many Rust primitive and standard library types.

This can also be automatically derived on most custom types with #[derive(JsonSchema)].

Example

use schemars::{schema_for, JsonSchema};

#[derive(JsonSchema)]
struct MyStruct {
    foo: i32,
}

let my_schema = schema_for!(MyStruct);

Required methods

fn schema_name() -> String

The name of the generated JSON Schema.

This is used as the title for root schemas, and the key within the root's definitions property for subschemas.

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type.

If the returned schema depends on any referenceable schemas, then this method will add them to the SchemaGenerator's schema definitions.

This should not return a $ref schema.

Loading content...

Provided methods

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword.

For trivial types (such as primitives), this should return false. For more complex types, it should return true. For recursive types, this must return true to prevent infinite cycles when generating schemas.

By default, this returns true.

Loading content...

Implementations on Foreign Types

impl JsonSchema for i8[src]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> JsonSchema for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) where
    T0: JsonSchema,
    T1: JsonSchema,
    T10: JsonSchema,
    T11: JsonSchema,
    T12: JsonSchema,
    T13: JsonSchema,
    T14: JsonSchema,
    T15: JsonSchema,
    T2: JsonSchema,
    T3: JsonSchema,
    T4: JsonSchema,
    T5: JsonSchema,
    T6: JsonSchema,
    T7: JsonSchema,
    T8: JsonSchema,
    T9: JsonSchema
[src]

impl JsonSchema for NonZeroI8[src]

impl JsonSchema for Number[src]

impl<T> JsonSchema for [T; 29] where
    T: JsonSchema
[src]

impl JsonSchema for CStr[src]

impl<T> JsonSchema for [T; 27] where
    T: JsonSchema
[src]

impl JsonSchema for Duration[src]

impl JsonSchema for u64[src]

impl JsonSchema for NonZeroI16[src]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> JsonSchema for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) where
    T0: JsonSchema,
    T1: JsonSchema,
    T10: JsonSchema,
    T11: JsonSchema,
    T12: JsonSchema,
    T2: JsonSchema,
    T3: JsonSchema,
    T4: JsonSchema,
    T5: JsonSchema,
    T6: JsonSchema,
    T7: JsonSchema,
    T8: JsonSchema,
    T9: JsonSchema
[src]

impl<T> JsonSchema for [T; 17] where
    T: JsonSchema
[src]

impl JsonSchema for AtomicI32[src]

impl JsonSchema for AtomicI8[src]

impl<T0, T1, T2, T3, T4, T5> JsonSchema for (T0, T1, T2, T3, T4, T5) where
    T0: JsonSchema,
    T1: JsonSchema,
    T2: JsonSchema,
    T3: JsonSchema,
    T4: JsonSchema,
    T5: JsonSchema
[src]

impl<T> JsonSchema for [T; 22] where
    T: JsonSchema
[src]

impl JsonSchema for ()[src]

impl<T> JsonSchema for RwLock<T> where
    T: JsonSchema + ?Sized
[src]

impl<T> JsonSchema for [T; 0][src]

impl<T> JsonSchema for [T; 15] where
    T: JsonSchema
[src]

impl JsonSchema for i32[src]

impl<T> JsonSchema for Reverse<T> where
    T: JsonSchema
[src]

impl JsonSchema for str[src]

impl<T> JsonSchema for BinaryHeap<T> where
    T: JsonSchema
[src]

impl<T> JsonSchema for RefCell<T> where
    T: JsonSchema + ?Sized
[src]

impl<'a, T> JsonSchema for Cow<'a, T> where
    T: ToOwned + JsonSchema + ?Sized
[src]

impl<T> JsonSchema for [T; 18] where
    T: JsonSchema
[src]

impl<T> JsonSchema for [T; 13] where
    T: JsonSchema
[src]

impl<T> JsonSchema for Range<T> where
    T: JsonSchema
[src]

impl JsonSchema for SocketAddrV4[src]

impl JsonSchema for SystemTime[src]

impl<T> JsonSchema for [T; 7] where
    T: JsonSchema
[src]

impl<T> JsonSchema for [T; 12] where
    T: JsonSchema
[src]

impl JsonSchema for NonZeroU64[src]

impl JsonSchema for NonZeroU128[src]

impl JsonSchema for NonZeroU16[src]

impl<T> JsonSchema for BTreeSet<T> where
    T: JsonSchema
[src]

impl JsonSchema for AtomicU16[src]

impl<T0, T1, T2, T3, T4> JsonSchema for (T0, T1, T2, T3, T4) where
    T0: JsonSchema,
    T1: JsonSchema,
    T2: JsonSchema,
    T3: JsonSchema,
    T4: JsonSchema
[src]

impl JsonSchema for char[src]

impl<T> JsonSchema for Wrapping<T> where
    T: JsonSchema
[src]

impl JsonSchema for i128[src]

impl<T> JsonSchema for Vec<T> where
    T: JsonSchema
[src]

impl JsonSchema for Path[src]

impl JsonSchema for bool[src]

impl<T> JsonSchema for PhantomData<T> where
    T: ?Sized
[src]

impl JsonSchema for usize[src]

impl JsonSchema for OsString[src]

impl<T, E> JsonSchema for Result<T, E> where
    E: JsonSchema,
    T: JsonSchema
[src]

impl<T> JsonSchema for Option<T> where
    T: JsonSchema
[src]

impl<T> JsonSchema for [T; 14] where
    T: JsonSchema
[src]

impl JsonSchema for Ipv4Addr[src]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> JsonSchema for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) where
    T0: JsonSchema,
    T1: JsonSchema,
    T10: JsonSchema,
    T11: JsonSchema,
    T2: JsonSchema,
    T3: JsonSchema,
    T4: JsonSchema,
    T5: JsonSchema,
    T6: JsonSchema,
    T7: JsonSchema,
    T8: JsonSchema,
    T9: JsonSchema
[src]

impl<T0, T1, T2> JsonSchema for (T0, T1, T2) where
    T0: JsonSchema,
    T1: JsonSchema,
    T2: JsonSchema
[src]

impl<T> JsonSchema for [T; 30] where
    T: JsonSchema
[src]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> JsonSchema for (T0, T1, T2, T3, T4, T5, T6, T7, T8) where
    T0: JsonSchema,
    T1: JsonSchema,
    T2: JsonSchema,
    T3: JsonSchema,
    T4: JsonSchema,
    T5: JsonSchema,
    T6: JsonSchema,
    T7: JsonSchema,
    T8: JsonSchema
[src]

impl JsonSchema for AtomicUsize[src]

impl JsonSchema for AtomicU8[src]

impl<T> JsonSchema for Box<T> where
    T: JsonSchema + ?Sized
[src]

impl<K, V, H> JsonSchema for HashMap<K, V, H> where
    V: JsonSchema
[src]

impl<T> JsonSchema for [T; 21] where
    T: JsonSchema
[src]

impl JsonSchema for u32[src]

impl JsonSchema for AtomicI16[src]

impl<T> JsonSchema for [T; 2] where
    T: JsonSchema
[src]

impl<T> JsonSchema for [T; 1] where
    T: JsonSchema
[src]

impl<T0, T1> JsonSchema for (T0, T1) where
    T0: JsonSchema,
    T1: JsonSchema
[src]

impl<T0, T1, T2, T3, T4, T5, T6, T7> JsonSchema for (T0, T1, T2, T3, T4, T5, T6, T7) where
    T0: JsonSchema,
    T1: JsonSchema,
    T2: JsonSchema,
    T3: JsonSchema,
    T4: JsonSchema,
    T5: JsonSchema,
    T6: JsonSchema,
    T7: JsonSchema
[src]

impl JsonSchema for AtomicIsize[src]

impl JsonSchema for AtomicI64[src]

impl JsonSchema for PathBuf[src]

impl JsonSchema for NonZeroUsize[src]

impl JsonSchema for Ipv6Addr[src]

impl<T> JsonSchema for Mutex<T> where
    T: JsonSchema + ?Sized
[src]

impl JsonSchema for i16[src]

impl<T, H> JsonSchema for HashSet<T, H> where
    T: JsonSchema
[src]

impl JsonSchema for f32[src]

impl<T> JsonSchema for [T; 3] where
    T: JsonSchema
[src]

impl JsonSchema for SocketAddr[src]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> JsonSchema for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) where
    T0: JsonSchema,
    T1: JsonSchema,
    T2: JsonSchema,
    T3: JsonSchema,
    T4: JsonSchema,
    T5: JsonSchema,
    T6: JsonSchema,
    T7: JsonSchema,
    T8: JsonSchema,
    T9: JsonSchema
[src]

impl<K, V> JsonSchema for BTreeMap<K, V> where
    V: JsonSchema
[src]

impl<T> JsonSchema for [T; 8] where
    T: JsonSchema
[src]

impl<T> JsonSchema for Weak<T> where
    T: JsonSchema + ?Sized
[src]

impl<T> JsonSchema for Bound<T> where
    T: JsonSchema
[src]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> JsonSchema for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) where
    T0: JsonSchema,
    T1: JsonSchema,
    T10: JsonSchema,
    T11: JsonSchema,
    T12: JsonSchema,
    T13: JsonSchema,
    T2: JsonSchema,
    T3: JsonSchema,
    T4: JsonSchema,
    T5: JsonSchema,
    T6: JsonSchema,
    T7: JsonSchema,
    T8: JsonSchema,
    T9: JsonSchema
[src]

impl<T> JsonSchema for [T; 23] where
    T: JsonSchema
[src]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> JsonSchema for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) where
    T0: JsonSchema,
    T1: JsonSchema,
    T10: JsonSchema,
    T11: JsonSchema,
    T12: JsonSchema,
    T13: JsonSchema,
    T14: JsonSchema,
    T2: JsonSchema,
    T3: JsonSchema,
    T4: JsonSchema,
    T5: JsonSchema,
    T6: JsonSchema,
    T7: JsonSchema,
    T8: JsonSchema,
    T9: JsonSchema
[src]

impl<T> JsonSchema for Arc<T> where
    T: JsonSchema + ?Sized
[src]

impl JsonSchema for OsStr[src]

impl JsonSchema for NonZeroU8[src]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> JsonSchema for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) where
    T0: JsonSchema,
    T1: JsonSchema,
    T10: JsonSchema,
    T2: JsonSchema,
    T3: JsonSchema,
    T4: JsonSchema,
    T5: JsonSchema,
    T6: JsonSchema,
    T7: JsonSchema,
    T8: JsonSchema,
    T9: JsonSchema
[src]

impl<T0, T1, T2, T3> JsonSchema for (T0, T1, T2, T3) where
    T0: JsonSchema,
    T1: JsonSchema,
    T2: JsonSchema,
    T3: JsonSchema
[src]

impl<T> JsonSchema for [T; 10] where
    T: JsonSchema
[src]

impl JsonSchema for AtomicU32[src]

impl JsonSchema for f64[src]

impl<T> JsonSchema for LinkedList<T> where
    T: JsonSchema
[src]

impl<T> JsonSchema for [T; 20] where
    T: JsonSchema
[src]

impl<T> JsonSchema for [T; 19] where
    T: JsonSchema
[src]

impl<T> JsonSchema for Cell<T> where
    T: JsonSchema + ?Sized
[src]

impl<T> JsonSchema for [T; 4] where
    T: JsonSchema
[src]

impl<T0, T1, T2, T3, T4, T5, T6> JsonSchema for (T0, T1, T2, T3, T4, T5, T6) where
    T0: JsonSchema,
    T1: JsonSchema,
    T2: JsonSchema,
    T3: JsonSchema,
    T4: JsonSchema,
    T5: JsonSchema,
    T6: JsonSchema
[src]

impl JsonSchema for isize[src]

impl<T> JsonSchema for [T; 26] where
    T: JsonSchema
[src]

impl<T> JsonSchema for [T; 31] where
    T: JsonSchema
[src]

impl<'a, T> JsonSchema for &'a mut T where
    T: JsonSchema + ?Sized
[src]

impl<T> JsonSchema for Weak<T> where
    T: JsonSchema + ?Sized
[src]

impl JsonSchema for u128[src]

impl<T> JsonSchema for Rc<T> where
    T: JsonSchema + ?Sized
[src]

impl<T> JsonSchema for VecDeque<T> where
    T: JsonSchema
[src]

impl<T> JsonSchema for [T; 5] where
    T: JsonSchema
[src]

impl<T> JsonSchema for [T; 25] where
    T: JsonSchema
[src]

impl JsonSchema for NonZeroI32[src]

impl<T> JsonSchema for [T; 9] where
    T: JsonSchema
[src]

impl JsonSchema for Map<String, Value>[src]

impl<T0> JsonSchema for (T0,) where
    T0: JsonSchema
[src]

impl JsonSchema for IpAddr[src]

impl<T> JsonSchema for [T; 16] where
    T: JsonSchema
[src]

impl JsonSchema for AtomicBool[src]

impl JsonSchema for SocketAddrV6[src]

impl<'a> JsonSchema for Arguments<'a>[src]

impl JsonSchema for i64[src]

impl JsonSchema for u8[src]

impl JsonSchema for u16[src]

impl<T> JsonSchema for [T; 32] where
    T: JsonSchema
[src]

impl JsonSchema for NonZeroI64[src]

impl<T> JsonSchema for [T; 11] where
    T: JsonSchema
[src]

impl JsonSchema for NonZeroU32[src]

impl JsonSchema for NonZeroIsize[src]

impl<'a, T> JsonSchema for &'a T where
    T: JsonSchema + ?Sized
[src]

impl JsonSchema for CString[src]

impl<T> JsonSchema for [T; 28] where
    T: JsonSchema
[src]

impl<T> JsonSchema for RangeInclusive<T> where
    T: JsonSchema
[src]

impl JsonSchema for Value[src]

impl<T> JsonSchema for [T; 24] where
    T: JsonSchema
[src]

impl JsonSchema for AtomicU64[src]

impl JsonSchema for String[src]

impl JsonSchema for NonZeroI128[src]

impl<T> JsonSchema for [T; 6] where
    T: JsonSchema
[src]

Loading content...

Implementors

Loading content...