1.5 KiB
1.5 KiB
| layout | title | nav_order | permalink |
|---|---|---|---|
| default | Feature Flags | 5 | /features/ |
Feature Flags and Optional Dependencies
derive(enabled by default) - provides#[derive(JsonSchema)]macroimpl_json_schema- implementsJsonSchemafor Schemars types themselvespreserve_order- keep the order of struct fields inSchemaandSchemaObject
Schemars can implement JsonSchema on types from several popular crates, enabled via feature flags (dependency versions are shown in brackets):
chrono- chrono (^0.4)indexmap1- indexmap (^1.2)either- either (^1.3)uuid08- uuid (^0.8)uuid1- uuid (^1.0)smallvec- smallvec (^1.0)arrayvec05- arrayvec (^0.5)arrayvec07- arrayvec (^0.7)url- url (^2.0)bytes- bytes (^1.0)enumset- enumset (^1.0)rust_decimal- rust_decimal (^1.0)bigdecimal- bigdecimal (^0.3)
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"] }