NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #494 most downloaded on crates.io
Macros for #[derive(JsonSchema)], for use with schemars
Last release 2 months ago
27 Jul 2026
Release timing varies
gaps range from 8 days to 6 months
Most releases are documented
notes for 48 of 60 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
93 releases · first in 2019
Update to syn 3 in schemars_derive
transform attributes are now applied after the schema is otherwise fully constructed. In particular, they're now applied after all other attributes ar
transform attributes are now applied after the schema is otherwise fully constructed. In particular, they're now applied after all other attributes are processed. (#505)One column per quarter.
Schemas generated for HashMap / BTreeMap with enum keys are now more specific
HashMap/BTreeMap with enum keys are now more specific (https://github.com/GREsau/schemars/pull/452)Public functions that have no side-effects are now marked with #[must_use] so that they report a lint warning when the returned value is unused, as th
#[must_use] so that they report a lint warning when the returned value is unused, as this likely indicates a mistake.Fix schema.pointer_mut() to resolve URI fragment identifiers like #/$defs/foo , matching current behaviour of schema.pointer() ( #478 / #479 )
Fix JsonSchema impl on atomic types being ignored on non-nightly compilers due to a buggy cfg check
JsonSchema impl on atomic types being ignored on non-nightly compilers due to a buggy cfg check (https://github.com/GREsau/schemars/issues/453)syn (https://github.com/GREsau/schemars/issues/450)Fix compile error when a doc comment is set on both a transparent (or newtype) struct and its field
Fix schema properties being incorrectly reordered during serialization
Deriving JsonSchema with no_std broken due to std::ToOwned trait not being in scope
JsonSchema with no_std broken due to std::borrow::ToOwned trait not being in scope (#441)This is a major release with many additions, fixes and changes since 0.8 (but not many since 0.9). While the basic usage (deriving JsonSchema and usin
This is a major release with many additions, fixes and changes since 0.8 (but not many since 0.9). While the basic usage (deriving JsonSchema and using schema_for!() or SchemaGenerator) is mostly unchanged, you may wish to consult the migration guide which covers some of the most significant changes.
Changes since 1.0.0-rc.2:
#[schemars(bound = ...)] attributes are now used from fields as well as containersSchema::pointer(...) method now works when given a JSON pointer in URI Fragment representation with a leading # character. In particular, this means that you can now lookup a schema from a $ref value using that method.⚠️ Deprecated items have been removed:
#[schemars(!from)] (https://github.com/GREsau/schemars/issues/433 / https://github.com/GREsau/schemars/pull/434)SchemaSettings::option_nullable and SchemaSettings::option_add_null_type fieldsgen moduleImpl JsonSchema for chrono::TimeDelta
JsonSchema for chrono::TimeDelta (https://github.com/GREsau/schemars/issues/357)with/into/from/try_from container attributes (https://github.com/GREsau/schemars/issues/210 / https://github.com/GREsau/schemars/issues/267)oneOf when generating schema for serialized mixed-type sequences (https://github.com/GREsau/schemars/issues/348) - the previous behaviour was to always use true schema (i.e. any value) for mixed-type sequencesType and const generic params can now be used in schema_with attributes, e.g. #[schemars(schema_with = "func:: ")]
schema_with attributes, e.g. #[schemars(schema_with = "func::<T>")] (https://github.com/GREsau/schemars/pull/426 / https://github.com/GREsau/schemars/issues/375)Type params that are only used in skipped fields or PhantomData no longer have an unnecessary JsonSchema bound automatically added
PhantomData no longer have an unnecessary JsonSchema bound automatically addedschema_name() whether or not they impl JsonSchema. Type params can still be included in the name by specifying them in a rename attribute."$ref": "#" instead of duplicating the entire schema within $defs/definitions (https://github.com/GREsau/schemars/pull/418 / https://github.com/GREsau/schemars/issues/175)"title" set to the variant name (added in alpha.19) by default, but this behaviour is still available by setting the untagged_enum_variant_titles flag on SchemaSettings. (https://github.com/GREsau/schemars/pull/421 / https://github.com/GREsau/schemars/issues/420)Add get_mut, pointer, pointer_mut methods for easier manipulation of Schemas
get_mut, pointer, pointer_mut methods for easier manipulation of Schemas (#416)patternProperties on map schemas where appropriate (#417)
BTreeMap<K,V>/HashMap<K,V> now only implement JsonSchema when both K and V implement JsonSchematransparent, don't ignore other attributes (#415)Support #[serde(untagged)] on individual variants of enums
#[serde(untagged)] on individual variants of enums (https://github.com/GREsau/schemars/issues/388 / https://github.com/GREsau/schemars/pull/412)"title" to variant name in schemas for untagged enums/variants (https://github.com/GREsau/schemars/issues/102 / https://github.com/GREsau/schemars/pull/413)"description" from rust doc comments, trim a single leading space from the comment (https://github.com/GREsau/schemars/pull/407)with/serialize_with attributes will now fail compilation rather than being silently ignored (https://github.com/GREsau/schemars/pull/410)include_type_name setting for including "x-rust-type" property on generated schemas, since it didn't solve the original feature request. If you have a use-case for that behaviour, please raise an issue in GitHub.GenTransform::as_any and GenTransform::as_any are deprecated and will be removed before schemars 1.0 becomes stable.
#[schemars(inline)] attribute for inling schemas when deriving JsonSchema (https://github.com/GREsau/schemars/pull/380)JsonSchema for jiff 0.2 types, under the optional jiff02 feature flag (https://github.com/GREsau/schemars/pull/364)dyn GenTransform, allowing to to be used similarly to a dyn Any:
fn is<T>(&self) -> boolfn downcast_ref<T>(&self) -> Option<&T>fn downcast_mut<T>(&mut self) -> Option<&mut T>fn downcast<T>(self: Box<Self>) -> Result<Box<T>, Box<Self>>i8/i16/u8/u16 now include minimum and maximum properties (https://github.com/GREsau/schemars/issues/298)schemars::transform::RestrictFormats - a Transform that removes any format values that are not defined by the JSON Schema standard (or explicitly allowed by a custom list). This can be used to remove non-standard formats from schemas.SchemaSettings now has an include_type_name flag. When enabled, this includes an "x-rust-type" property on generated schemas, set to the name of the schema's associated rust type.JsonSchema::always_inline_schema() to inline_schema(), because future attributes may allow particular fields to be uninlinedGenTransform::as_any and GenTransform::as_any are deprecated and will be removed before schemars 1.0 becomes stable.Option<T>) has been reworked, making them more accurate. The SchemaSettings::option_nullable and SchemaSettings::option_add_null_type fields are no longer used - instead, generated schemas always include the "null" type, but this can be changed to nullable by using the new AddNullable transform.SchemaSettings::meta_schema and SchemaSettings::definitions_path from String to Cow<'static, str>, making it easier to construct a SchemaSettings in a const context.SchemaGenerator::take_definitions method now takes an apply_transforms flag, which when enabled, will apply the generator's current transforms to each of the schema values in the returned map.For newtype variants of internally-tagged enums, prefer referencing the inner type's schema via $ref instead of always inlining the schema (https://gi
$ref instead of always inlining the schema (https://github.com/GREsau/schemars/pull/355) (this change was included in the release notes for 1.0.0-alpha.16, but was accidentally excluded from the published crate)the enumset1/enumset optional dependency has been removed, as its JsonSchema impl did not actually match the default serialization format of EnumSet
enumset1/enumset optional dependency has been removed, as its JsonSchema impl did not actually match the default serialization format of EnumSet (https://github.com/GREsau/schemars/pull/339)example attribute value is now an arbitrary expression, rather than a string literal identifying a function to call. To avoid silent behaviour changes, the expression must not be a string literal where the value can be parsed as a function path - e.g. #[schemars(example = "foo")] is now a compile error, but #[schemars(example = foo())] is allowed (as is #[schemars(example = &"foo")] if you want the the literal string value "foo" to be the example).bytes::Bytes/BytesMut now allows strings, matching the actual deserialize behaviour of the types.either::Either now matches the actual serialize/deserialize behaviour of that type.SchemaSettings now has a contract field which determines whether the generated schemas describe how types are serialized or *de*serialized. By default
SchemaSettings now has a contract field which determines whether the generated schemas describe how types are serialized or deserialized. By default, this is set to Deserialize, as this more closely matches the behaviour of previous versions - you can change this to Serialize to instead generate schemas describing the type's serialization behaviour (https://github.com/GREsau/schemars/issues/48 / https://github.com/GREsau/schemars/pull/335)false (or equivalently {"not":{}}), instead of {"enum":[]}. This is so generated schemas no longer violate the JSON Schema spec's recommendation that a schema's enum array "SHOULD have at least one element".Read #[garde(...)] attributes as an alternative to #[validate(...)] (https://github.com/GREsau/schemars/issues/233 / https://github.com/GREsau/schemar
#[garde(...)] attributes as an alternative to #[validate(...)] (https://github.com/GREsau/schemars/issues/233 / https://github.com/GREsau/schemars/pull/331). See the documentation for a full list of supported attributes.Fix compile errors when using #[validate(regex(path = *expr))] attribute
#[validate(regex(path = *expr))] attributeAllow regex(path = ...) value to be a non-string expression
regex(path = ...) value to be a non-string expression (https://github.com/GREsau/schemars/issues/302 / https://github.com/GREsau/schemars/pull/328)#[serde(rename_all_fields = ...)] attribute (https://github.com/GREsau/schemars/issues/273 / https://github.com/GREsau/schemars/pull/304)schema_with on structs) will now cause compile errorsphone attributerequired_nested attributeregex and contains attributes must now be specified in list form #[validate(regex(path = ...))] rather than name/value form #[validate(regex = ...)]Values in #[doc = ...] and #[schemars(description = ..., title = ...)] attributes may now be any arbitrary expression rather than just string literals
#[doc = ...] and #[schemars(description = ..., title = ...)] attributes may now be any arbitrary expression rather than just string literals. (https://github.com/GREsau/schemars/issues/204 / https://github.com/GREsau/schemars/pull/327)Fix some cases of unsatisfiable schemas generated when flattening enums
Add rustdoc for derive(JsonSchema) macro
derive(JsonSchema) macro (https://github.com/GREsau/schemars/issues/322 / https://github.com/GREsau/schemars/issues/322)The schemars::gen module is still available for ease of upgrading, but is marked as deprecated and _may_ be removed in the future 1.0.0 release.
schemars::gen module with schemars::generate. This is because gen is a reserved keyword in rust 2024, so can only be used as r#gen. The schemars::gen module is still available for ease of upgrading, but is marked as deprecated and may be removed in the future 1.0.0 release. (https://github.com/GREsau/schemars/issues/306 / https://github.com/GREsau/schemars/pull/323)Fix behaviour of flatten for schemas with additionalProperties
flatten for schemas with additionalPropertiesflatten of multiple enums (https://github.com/GREsau/schemars/issues/165 / https://github.com/GREsau/schemars/pull/320)Fixed a configuration error that caused rustdoc generation to fail on docs.rs
Schemars can now be used in no_std environments by disabling the new std feature flag (which is enabled by default). Schemars still requires an alloca
no_std environments by disabling the new std feature flag (which is enabled by default). Schemars still requires an allocator to be available.Reduce size of MIR output (and improve release-mode compile time) when deriving JsonSchema involving applying schema metadata
JsonSchema involving applying schema metadataflattening of serde_json::ValueResult in derive output, ignoring any locally imported types called Result (https://github.com/GREsau/schemars/pull/307)SchemaSettings and SchemaGenerator are both now Send
#[schemars(transform = some::transform)] for applying arbitrary modifications to generated schemas. some::transform must be an expression of type schemars::transform::Transform - note that this can be a function with the signature fn(&mut Schema) -> ().SchemaSettings and SchemaGenerator are both now Sendvisit module and Visitor trait have been replace with transform and Transform respectively. Accordingly, these items have been renamed:
SchemaSettings::visitors -> SchemaSettings::transformsSchemaSettings::with_visitor -> SchemaSettings::with_transformSchemaGenerator::visitors_mut -> SchemaGenerator::transforms_mutGenVisitor -> GenTransformVisitor::visit_schema -> Transform::transformvisit::visit_schema -> transform::transform_subschemasGenTransform must also impl Send, but no longer needs to impl Debugdescription property (https://github.com/GREsau/schemars/pull/310)Can be set on a struct, enum, or enum variant
#[schemars(extend("key" = value))] attribute which can be used to add properties (or replace existing properties) in a generated schema (https://github.com/GREsau/schemars/issues/50 / https://github.com/GREsau/schemars/pull/297)
Serializeserde_json::json!(value) macro, i.e. it can interpolate other values that implement SerializeRemoved deprecated SchemaGenerator methods make_extensible, schema_for_any and schema_for_none
json_schema! macro for creating a custom SchemaJsonSchema for uuid 1.x types, under the optional uuid1 feature flagSchemaSettings::draft2020_12() to construct settings conforming to JSON Schema draft 2020-12Schema type is now defined as a thin wrapper around a serde_json::ValueSchemaSettings (used by the schema_for!()/schema_for_value!() macros and SchemaGenerator::default()) now conform to JSON Schema draft 2020-12 instead of draft 7.SchemaSettings::draft2019_09() (and draft2020_12() and default()) now use $defs instead of definitions. While using definitions is allowed by the spec, $defs is the preferred property for storing reusable schemas.JsonSchema::schema_name() now returns Cow<'static, str> instead of StringJsonSchema::is_referenceable() has been removed, and replaced with the more clearly-named JsonSchema::always_inline_schema() (which should returns the opposite value to what is_referenceable returned!)SchemaGenerator.definitions field is now a serde_json::Map<String, Value>RootSchema now return a Schema insteadchrono is now chrono04either is now either1smallvec is now smallvec1url is now url2bytes is now bytes1rust_decimal is now rust_decimal1enumset is now enumset1smol_str is now smol_str02semver is now semver1indexmap2, arrayvec07 and bigdecimal04 are unchangedSchemaGenerator methods make_extensible, schema_for_any and schema_for_noneschema module
Schema type is now accessible from the crate root (i.e. schemars::Schema instead of schemars::schema::Schema)RootSchemaSchemaObjectMetadataSubschemaValidationNumberValidationStringValidationArrayValidationObjectValidationInstanceTypeSingleOrVecschemars::Set and schemars::Map type aliasesimpl_json_schema feature flag - JsonSchema is now always implemented on Schemavisit_schema_object and visit_root_schema from the Visitor trait (visit_schema is unchanged)
visit_schema_object should instead define visit_schema and use an if let Some(obj) = schema.as_object_mut() or similar constructindexmap (consider using indexmap2)uuid08 (consider using uuid1)arrayvec05 (consider using arrayvec07)bigdecimal03 (consider using bigdecimal04)This version is identical to 1.0.0-alpha.18, but is available for those who are unable to unwilling to use a pre-release version.
This version is identical to 1.0.0-alpha.18, but is available for those who are unable to unwilling to use a pre-release version.
Those upgrading from Schemars 0.8 may want to consult the migration guide, which also applies when migrating from 0.8 to 0.9.
Fix compatibility with rust 2024 edition
Fix null default not being set on generated schemas
null default not being set on generated schemas (https://github.com/GREsau/schemars/issues/295 / https://github.com/GREsau/schemars/pull/296)Revert unintentional change in behaviour when combining default and required attributes
default and required attributes (https://github.com/GREsau/schemars/issues/292)Regression that caused a compile error when deriving JsonSchema on an enum with no variants
JsonSchema on an enum with no variants (https://github.com/GREsau/schemars/issues/287)Reduce size of MIR output (and improve release-mode compile time) when deriving JsonSchema on enums
JsonSchema on enums (https://github.com/GREsau/schemars/pull/266 / https://github.com/GREsau/schemars/pull/286)Update to syn 2.0, which should improve compile times in many cases
Reduce size of MIR output (and improve release-mode compile time) when deriving JsonSchema
JsonSchemaImplement JsonSchema for BigDecimal from bigdecimal 0.4
JsonSchema for BigDecimal from bigdecimal 0.4 (https://github.com/GREsau/schemars/pull/237)Add #[schemars(inner(...)] attribute to specify schema for array items
#[schemars(inner(...)] attribute to specify schema for array items (https://github.com/GREsau/schemars/pull/234)JsonSchema trait: schema_id(), which is similar to schema_name(), but does not have to be human-readable, and defaults to the type name including module path. This allows schemars to differentiate between types with the same name in different modules/crates (https://github.com/GREsau/schemars/issues/62 / https://github.com/GREsau/schemars/pull/247)rust_decimal::Decimal and bigdecimal::BigDecimal now match how those types are serialized by default, i.e. as numeric strings (https://github.com/GREsau/schemars/pull/248)Implement JsonSchema for semver::Version
JsonSchema for semver::Version (https://github.com/GREsau/schemars/pull/195 / https://github.com/GREsau/schemars/pull/238)JsonSchema for types from indexmap v2 (https://github.com/GREsau/schemars/pull/226 / https://github.com/GREsau/schemars/pull/240)JsonSchema for serde_json::value::RawValue (https://github.com/GREsau/schemars/pull/183)Implement JsonSchema for smol_str::SmolStr
JsonSchema for smol_str::SmolStr (https://github.com/GREsau/schemars/pull/72)serde_json dependency min version to 1.0.25 (was 1.0.0) (https://github.com/GREsau/schemars/pull/192)Replace auto-inferred trait bounds with bounds specified in #[schemars(bound = "...")] attribute
#[schemars(bound = "...")] attributeJsonSchema now respects attributes on unit enum variants (https://github.com/GREsau/schemars/pull/152)…as it inadvertently introduced a breaking change
This inadvertently introduced a breaking change and was removed in 0.8.10
default attributes (https://github.com/GREsau/schemars/pull/83)uuid1 and arrayvec07 (https://github.com/GREsau/schemars/pull/142)
uuid08 and arrayvec05 feature flags for the previously supported versions of these crates. The existing uuid and arrayvec flags are still supported for backward-compatibility, but they are deprecated.indexmap1 feature flag is added, and indexmap flag is deprecated.Implement JsonSchema for types from rust_decimal and bigdecimal crates
JsonSchema for types from rust_decimal and bigdecimal crates (https://github.com/GREsau/schemars/pull/101)Implement JsonSchema for EnumSet
JsonSchema for EnumSet (https://github.com/GREsau/schemars/pull/92)Serialize (https://github.com/GREsau/schemars/issues/115)Use oneOf instead of anyOf for enums when possible
oneOf instead of anyOf for enums when possible (https://github.com/GREsau/schemars/issues/108)Allow fields with plain #[validate] attributes
#[validate] attributes (https://github.com/GREsau/schemars/issues/109)Deriving JsonSchema will now take into account #[validate(...)] attributes, compatible with the validator crate
#[schemars(schema_with = "...")] attribute can now be set on enum variants.#[validate(...)] attributes, compatible with the validator crate (https://github.com/GREsau/schemars/pull/78)Support for #[schemars(crate = "...")] attribute to allow deriving JsonSchema when the schemars crate is aliased to a different name
#[schemars(crate = "...")] attribute to allow deriving JsonSchema when the schemars crate is aliased to a different name (https://github.com/GREsau/schemars/pull/55 / https://github.com/GREsau/schemars/pull/80)JsonSchema for bytes::Bytes and bytes::BytesMut (https://github.com/GREsau/schemars/pull/68)Enable generating a schema from any serializable value using schema_for_value!(...) macro or SchemaGenerator::root_schema_for_value()/SchemaGenerator:
schema_for_value!(...) macro or SchemaGenerator::root_schema_for_value()/SchemaGenerator::into_root_schema_for_value() methods (https://github.com/GREsau/schemars/pull/75)#[derive(JsonSchema_repr)] can be used on C-like enums for generating a serde_repr-compatible schema (https://github.com/GREsau/schemars/pull/76)JsonSchema for url::Url (https://github.com/GREsau/schemars/pull/63)SchemaGenerator::definitions_mut() which returns a mutable reference to the generator's schema definitions
SchemaGenerator::definitions_mut() which returns a mutable reference to the generator's schema definitionsJsonSchema for slicesadditionalProperties to false on generated schemas wherever serde doesn't accept unknown properties. This includes non-unit variants of externally tagged enums, and struct-style variants of all enums that have the deny_unknown_fields attribute.uniqueItems set to true (https://github.com/GREsau/schemars/pull/64)#[serde(transparent)] in combination with #[schemars(with = ...)] (https://github.com/GREsau/schemars/pull/67)field_reassign_with_default warning in schemars_derive generated code in rust <1.51 (https://github.com/GREsau/schemars/pull/65)inline_subschemas with recursive typesBREAKING CHANGE Minimum supported rust version is now 1.36.0
visit::Visitor, a trait for updating a schema and all schemas it contains recursively. A SchemaSettings can now contain a list of visitors.into_object() method added to Schema as a shortcut for into::<SchemaObject>()preserve_order feature flag (https://github.com/GREsau/schemars/issues/32)SchemaGenerator::take_definitions() which behaves similarly to the now-removed into_definitions() method but without consuming the generatorSchemaGenerator::visitors_mut() which returns an iterator over a generator's settings's visitorsSchemaSettings::inline_subschemas - enforces inlining of all subschemas instead of using references (https://github.com/GREsau/schemars/issues/44)SchemaSettings::bool_schemas - this has been superseded by the ReplaceBoolSchemas visitorSchemaSettings::allow_ref_siblings - this has been superseded by the RemoveRefSiblings visitorSchemaSettings no longer implements PartialEqSchemaGenerator::into_definitions() - this has been superseded by SchemaGenerator::take_definitions()#[schemars(...)] attributes now cause a compilation error (https://github.com/GREsau/schemars/issues/18)make_extensible, schema_for_any, and schema_for_none methods on SchemaGeneratorNothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →