[x] Where we currently use a single-valued enum, instead use const (check which schema versions support const - may require a new visitor to change const to enum) - #291
[ ] Ensure compile times are OK for deriving JsonSchema on large types. Potentially reduce usages of json!/json_schema! for better performance, particularly in schemars_derive
[x] Review doc comments
[x] Update documentation
[x] Review the behaviour of with/schema_with on enum variants - I think the current behaviour is inconsistent with how serde performs (de)serialization
[x] move private Schema::flatten function to _private
[x] flatten has been rewritten but I'm not confident that the new (or old tbh!) behaviour is correct in all cases- validate behaviour when flattening a normal struct into a struct with deny_unknown_fields
[x] Regenerate schemas for tests and examples, remove TempFixupForTests
[x] Re-add test coverage of different schema generator settings e.g. openapi3, since the schema_for_schema tests were previously removed
[x] Maybe rename (and invert) is_referenceable() to always_inline()?
[x] Maybe change JsonSchema::schema_name() to return a Cow<'static, str> instead of always an owned String?
[x] Use $defs instead of definitions depending on json schema version
[x] Consider re-adding something like the preserve_order feature flag to preserve field order in schemas
[x] Support draft 2020-12, and use it by default
[x] Consider making SchemaGenerator run visitors against definitions lazily again so that in general, a visitor can be run against any root schema and actually visit all subschemas. But what to do when definitions are not under definitions or $defs (e.g. in openapi3)?
Breaking changes (so far):
Methods that were deprecated are now removed
Schema is now defined as a wrapper around a serde_json::Value (which must be a Value::Bool or Value::Object), rather than a struct with a field for each JSON schema keyword (with some intermediary types). Schema is now available as schemars::Schema instead of schemars::schema::Schema, and all other types that were in the schemars::schema module have now been removed
functions that previously returned a RootSchema now just return a Schema
schemars no longer has its own Map/Set type aliases
The SchemaGenerator.definitions field is now a serde_json::Map<String, serde_json::Value> (ideally it would be some sort of Map<String, Schema>, but serde_json::Map only really works with a plain Value)
The impl_json_schema feature flag has been removed - JsonSchema is now always implemented on Schema
JsonSchema::schema_name() now returns Cow<'static, str> instead of String
JsonSchema::is_referenceable() has been removed, and replaced with JsonSchema::always_inline() which should returns the opposite value
All optional dependencies are now suffixed by their version:
chrono is now chrono04
either is now either1
smallvec is now smallvec1
url is now url2
bytes is now bytes1
rust_decimal is now rust_decimal1
enumset is now enumset1
smol_str is now smol_str02
semver is now semver1
indexmap, uuid08, arrayvec05 and bigdecimal03 have been removed
indexmap2, arrayvec07 and bigdecimal04 are unchanged
Remove the retain_examples field from SetSingleExample, which is now a unit struct
Newlines in doc comments are no longer collapsed when generating description
visit module and Visitor trait have been replace with transform and Transform respectively. Accordingly, these items have been renamed:
Still to do:
enum
, instead useconst
(check which schema versions supportconst
- may require a new visitor to changeconst
toenum
) - #291JsonSchema
on large types. Potentially reduce usages ofjson!
/json_schema!
for better performance, particularly in schemars_derivewith
/schema_with
on enum variants - I think the current behaviour is inconsistent with how serde performs (de)serializationSchema::flatten
function to_private
flatten
has been rewritten but I'm not confident that the new (or old tbh!) behaviour is correct in all cases- validate behaviour when flattening a normal struct into a struct withdeny_unknown_fields
TempFixupForTests
openapi3
, since the schema_for_schema tests were previously removedis_referenceable()
toalways_inline()
?JsonSchema::schema_name()
to return aCow<'static, str>
instead of always an ownedString
?$defs
instead ofdefinitions
depending on json schema versionpreserve_order
feature flag to preserve field order in schemasdefinitions
or$defs
(e.g. in openapi3)?Breaking changes (so far):
Schema
is now defined as a wrapper around aserde_json::Value
(which must be aValue::Bool
orValue::Object
), rather than a struct with a field for each JSON schema keyword (with some intermediary types).Schema
is now available asschemars::Schema
instead ofschemars::schema::Schema
, and all other types that were in theschemars::schema
module have now been removedRootSchema
now just return aSchema
Map
/Set
type aliasesSchemaGenerator.definitions
field is now aserde_json::Map<String, serde_json::Value>
(ideally it would be some sort ofMap<String, Schema>
, butserde_json::Map
only really works with a plainValue
)impl_json_schema
feature flag has been removed -JsonSchema
is now always implemented onSchema
JsonSchema::schema_name()
now returnsCow<'static, str>
instead ofString
JsonSchema::is_referenceable()
has been removed, and replaced withJsonSchema::always_inline()
which should returns the opposite valuechrono
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
indexmap
,uuid08
,arrayvec05
andbigdecimal03
have been removedindexmap2
,arrayvec07
andbigdecimal04
are unchangedretain_examples
field fromSetSingleExample
, which is now a unit structdescription
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_schema_object
andvisit_root_schema
methods have been removedvisit::visit_schema
->transform::transform_subschemas
visit_schema_object
andvisit_root_schema
functions have been removed