1.8 KiB
1.8 KiB
| title | nav_order | permalink |
|---|---|---|
| Feature Flags | 6 | /features/ |
Feature Flags and Optional Dependencies
std(enabled by default) - implementsJsonSchemafor types in the rust standard library (JsonSchemais still implemented on types incoreandalloc, even when this feature is disabled). Disable this feature to use schemars inno_stdenvironments.derive(enabled by default) - provides#[derive(JsonSchema)]macropreserve_order- keep the order of struct fields inSchemapropertiesraw_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):
arrayvec07- arrayvec (^0.7)bigdecimal04- bigdecimal (^0.4)bytes1- bytes (^1.0)chrono04- chrono (^0.4)either1- either (^1.3)enumset1- enumset (^1.0)indexmap2- indexmap (^2.0)rust_decimal1- rust_decimal (^1.0)semver1- semver (^1.0.9)smallvec1- smallvec (^1.0)smol_str02- smol_str (^0.2.1)url2- url (^2.0)uuid1- uuid (^1.0)
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.11", features = ["chrono04"] }