schemars/docs/4-features.md
2024-06-09 19:48:35 +01:00

1.6 KiB

title nav_order permalink
Feature Flags 5 /features/

Feature Flags and Optional Dependencies

  • 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.2", features = ["chrono04"] }