This page is for the current stable release of Schemars (v0.8.x).
To view this page for the v1 version of Schemars, which is still under development, click here.
Feature Flags and Optional Dependencies
derive
(enabled by default) - provides#[derive(JsonSchema)]
macroimpl_json_schema
- implementsJsonSchema
for Schemars types themselvespreserve_order
- keep the order of struct fields inSchema
andSchemaObject
raw_value
- implementsJsonSchema
forserde_json::value::RawValue
(enables the serde_jsonraw_value
feature)
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"] }