Releases: GREsau/schemars
Releases · GREsau/schemars
v1.0.0-alpha.5
Added
- Schemars can now be used in
no_std
environments by disabling the newstd
feature flag (which is enabled by default). Schemars still requires an allocator to be available.
v1.0.0-alpha.4
Fixed
- Reduce size of MIR output (and improve release-mode compile time) when deriving
JsonSchema
involving applying schema metadata - Fix
flatten
ing ofserde_json::Value
- Use absolute import for
Result
in derive output, ignoring any locally imported types calledResult
(#307)
v1.0.0-alpha.3
Added
#[schemars(transform = some::transform)]
for applying arbitrary modifications to generated schemas.some::transform
must be an expression of typeschemars::transform::Transform
- note that this can be a function with the signaturefn(&mut Schema) -> ()
.SchemaSettings
andSchemaGenerator
are both nowSend
Changed (⚠️ breaking changes ⚠️ )
visit
module andVisitor
trait have been replace withtransform
andTransform
respectively. Accordingly, these items have been renamed:SchemaSettings::visitors
->SchemaSettings::transforms
SchemaSettings::with_visitor
->SchemaSettings::with_transform
SchemaGenerator::visitors_mut
->SchemaGenerator::transforms_mut
GenVisitor
->GenTransform
Visitor::visit_schema
->Transform::transform
visit::visit_schema
->transform::transform_subschemas
GenTransform
must also implSend
, but no longer needs to implDebug
- Doc comments no longer have newlines collapsed when generating the
description
property (#310)
v1.0.0-alpha.2
Added
#[schemars(extend("key" = value))]
attribute which can be used to add properties (or replace existing properties) in a generated schema (#50 / #297)- Can be set on a struct, enum, or enum variant
- Value can be any expression that results in a value implementing
Serialize
- Value can also be a JSON literal following the rules of
serde_json::json!(value)
macro, i.e. it can interpolate other values that implementSerialize
v1.0.0-alpha.1
Added
json_schema!
macro for creating a customSchema
- Implement
JsonSchema
for uuid 1.x types, under the optionaluuid1
feature flag SchemaSettings::draft2020_12()
to construct settings conforming to JSON Schema draft 2020-12
Changed (⚠️ breaking changes ⚠️ )
- The
Schema
type is now defined as a thin wrapper around aserde_json::Value
- The default
SchemaSettings
(used by theschema_for!()
/schema_for_value!()
macros andSchemaGenerator::default()
) now conform to JSON Schema draft 2020-12 instead of draft 7. - Schemas generated using
SchemaSettings::draft2019_09()
(anddraft2020_12()
anddefault()
) now use$defs
instead ofdefinitions
. While usingdefinitions
is allowed by the spec,$defs
is the preferred property for storing reusable schemas. JsonSchema::schema_name()
now returnsCow<'static, str>
instead ofString
JsonSchema::is_referenceable()
has been removed, and replaced with the more clearly-namedJsonSchema::always_inline()
(which should returns the opposite value to whatis_referenceable
returned!)- The
SchemaGenerator.definitions
field is now aserde_json::Map<String, Value>
- Macros/functions that previously returned a
RootSchema
now return aSchema
instead - All optional dependencies are now suffixed by their version:
chrono
is nowchrono04
either
is noweither1
smallvec
is nowsmallvec1
url
is nowurl2
bytes
is nowbytes1
rust_decimal
is nowrust_decimal1
enumset
is nowenumset1
smol_str
is nowsmol_str02
semver
is nowsemver1
indexmap2
,arrayvec07
andbigdecimal04
are unchanged
Removed (⚠️ breaking changes ⚠️ )
- Removed deprecated
SchemaGenerator
methodsmake_extensible
,schema_for_any
andschema_for_none
- Removed the
schema
module- The
Schema
type is now accessible from the crate root (i.e.schemars::Schema
instead ofschemars::schema::Schema
) - All other types that were in the module have been removed:
RootSchema
SchemaObject
Metadata
SubschemaValidation
NumberValidation
StringValidation
ArrayValidation
ObjectValidation
InstanceType
SingleOrVec
- The
- Removed
schemars::Set
andschemars::Map
type aliases - Removed the
impl_json_schema
feature flag -JsonSchema
is now always implemented onSchema
- Remove methods
visit_schema_object
andvisit_root_schema
from theVisitor
trait (visit_schema
is unchanged)- Visitors that previously defined
visit_schema_object
should instead definevisit_schema
and use anif let Some(obj) = schema.as_object_mut()
or similar construct
- Visitors that previously defined
- Old versions of optional dependencies have been removed - all of these have newer versions (shown in brackets) which are supported by schemars
indexmap
(consider usingindexmap2
)uuid08
(consider usinguuid1
)arrayvec05
(consider usingarrayvec07
)bigdecimal03
(consider usingbigdecimal04
)
- Remove the retain_examples field from SetSingleExample, which is now a unit struct