schemars/docs/4-features.md
2023-08-27 23:01:12 +01:00

1.7 KiB

layout title nav_order permalink
default Feature Flags 5 /features/

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

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"] }