Link Search Menu Expand Document

Feature Flags and Optional Dependencies

  • derive (enabled by default) - provides #[derive(JsonSchema)] macro
  • impl_json_schema - implements JsonSchema for Schemars types themselves
  • preserve_order - keep the order of struct fields in Schema and SchemaObject
  • 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 = "0.8", features = ["chrono"] }