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.

Feature Flags and Optional Dependencies

  • std (enabled by default) - implements JsonSchema for types in the rust standard library (JsonSchema is still implemented on types in core and alloc, even when this feature is disabled). Disable this feature to use schemars in no_std environments.
  • derive (enabled by default) - provides #[derive(JsonSchema)] macro
  • preserve_order - keep the order of struct fields in Schema properties
  • raw_value - implements JsonSchema for serde_json::value::RawValue (enables the serde_json raw_value feature)

Schemars can implement JsonSchema on types from several popular crates, enabled via feature flags (dependency versions are shown in brackets):

For example, to implement JsonSchema on types from chrono, enable it as a feature in the schemars dependency in your Cargo.toml like so:

[dependencies]
schemars = { version = "1.0.0-alpha.17", features = ["chrono04"] }