This page is for the current v1 alpha version of Schemars. This version is still under development, and further breaking changes may be introduced.
To view this page for the current stable release of Schemars (v0.8.x), click here.
Examples
Table of contents
- Deriving JsonSchema - Deriving JsonSchema on a struct and enum.
- Using Serde Attributes - Deriving JsonSchema on types that use #[serde] attributes to customise serialization behaviour.
- Using Schemars Attributes - Deriving JsonSchema on types that use #[schemars] attributes to customise serialization behaviour.
- Custom Schema Settings - Generating a schema using custom settings which changes how Option
is handled. - Derive for Remote Crate - Deriving JsonSchema implementations for a type in somebody else's crate.
- Doc Comments - Giving schemas a custom title and/or description using doc comments.
- Custom Serialization - If a field has a #[serde(with = "path")] attribute where "path" is not a type that implements JsonSchema, then in order to derive JsonSchema on the type, it must also have a #[schemars(with = "Type")] attribute, where "Type" implements JsonSchema.
- Serialize Enum as Number (serde_repr) - Generating a schema for with a C-like enum compatible with serde_repr.
- Generate Schema from Example Value - Generating a schema for a serializable value.