1.9 KiB
1.9 KiB
| title | nav_order | permalink |
|---|---|---|
| Feature Flags | 5 | /v0/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 inSchemaandSchemaObjectraw_value- implementsJsonSchemaforserde_json::value::RawValue(enables the serde_jsonraw_valuefeature)
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)indexmap2- indexmap (^2.0)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)bigdecimal03- bigdecimal (^0.3)bigdecimal04- bigdecimal (^0.4)smol_str- smol_str (^0.1.17)semver- semver (^1.0.9)
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"] }