This page is for the current v1 alpha version of Schemars. This version is still under development, and further breaking changes may be introduced.
To view this page for the current stable release of Schemars (v0.8.x), click here.
Feature Flags and Optional Dependencies
std
(enabled by default) - implementsJsonSchema
for types in the rust standard library (JsonSchema
is still implemented on types incore
andalloc
, even when this feature is disabled). Disable this feature to use schemars inno_std
environments.derive
(enabled by default) - provides#[derive(JsonSchema)]
macropreserve_order
- keep the order of struct fields inSchema
propertiesraw_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):
arrayvec07
- arrayvec (^0.7)bigdecimal04
- bigdecimal (^0.4)bytes1
- bytes (^1.0)chrono04
- chrono (^0.4)either1
- either (^1.3)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.17", features = ["chrono04"] }