#[serde(with = "...")]
/#[schemars(with = "...")]
attributes on enum variants are now respected
- Enable deriving JsonSchema on adjacent tagged enums (GREsau#4)
- Added
examples
(https://tools.ietf.org/html/draft-handrews-json-schema-validation-02#section-9.5) toMetadata
- Fixed a bug in schemars_derive causing a compile error when the
default
,skip_serializing_if
, andserialize_with
/with
attributes are used together (GREsau#26)
- BREAKING CHANGE -
SchemaSettings
can no longer be created using struct initialization syntax. Instead, if you need to use custom schema settings, you can use a constructor function and either:- assign it to a
mut
variable and modify its public fields - call the
with(|s| ...)
method on the settings and modify the settings inside the closure/function (as in the custom_settings.rs example)
- assign it to a
- When deriving
JsonSchema
on structs,Option<T>
struct fields are no longer included in the list of required properties in the schema (GREsau#11) - Fix deriving
JsonSchema
when a non-stdString
type is in scope (GREsau#19) - This will now compile:
#[schemars(with="()")]
- Added
allow_ref_siblings
setting toSchemaSettings
. When enabled, schemas with a$ref
property may have other properties set. - Can create JSON Schema 2019-09 schemas using
SchemaSettings::draft2019_09()
(which enablesallow_ref_siblings
)
- Implemented
JsonSchema
on types fromsmallvec
andarrayvec
(as optional dependencies)
- Implemented
JsonSchema
on types fromindexmap
,either
anduuid
(as optional dependencies)
- Remove trait bounds from Map/Set JsonSchema impls. They are unnecessary as we never create/use any instances of these types.
- No actual code changes - this version was just published to fix broken README on crates.io
- Documentation website available at https://graham.cool/schemars/!
- Rename
derive_json_schema
toimpl_json_schema
.derive_json_schema
is still available for backward-compatibility, but will be removed in a future version. - Improve schema naming for deriving on remote types. A
#[serde(remote = "Duration")]
attribute is now treated similarly to#[serde(rename = "Duration")]
. - Ensure root schemas do not have a
$ref
property. If necessary, wrap the$ref
in anallOf
.
- Fix a compile error that can occur when deriving
JsonSchema
from a project that doesn't reference serde_json
- When deriving
JsonSchema
, the schema'stitle
anddescription
are now set from#[doc]
comments (GREsau#7) - When deriving
JsonSchema
on structs using a#[serde(default)]
attribute, the schema's properties will now includedefault
, unless the default value is skipped by the field'sskip_serializing_if
function (GREsau#6)
- When the
option_nullable
setting is enabled (e.g. for openapi 3), schemas forOption<T>
will no longer inlineT
's schema when it should be referenceable.
- Added missing doc comment for
title
schema property
- Implemented
JsonSchema
for more standard library types (GREsau#3)
- Unsigned integer types (usize, u8 etc.) now have their
minimum
explicitly set to zero - Made prepositions/conjunctions in generated schema names lowercase
- e.g. schema name for
Result<MyStruct, Vec<String>>
has changed from "Result_Of_MyStruct_Or_Array_Of_String" to "Result_of_MyStruct_or_Array_of_String"
- e.g. schema name for
- Some provided
JsonSchema
implementations with the sametype
but differentformat
s (e.g.i8
andusize
) used thetype
as their name. They have now been updated to useformat
as their name.- Previously, schema generation would incorrectly assume types such as
MyStruct<i8>
andMyStruct<usize>
were identical, and give them a single schema definition calledMyStruct_for_Integer
despite the fact they should have different schemas. Now they will each have their own schema (MyStruct_for_i8
andMyStruct_for_usize
respectively).
- Previously, schema generation would incorrectly assume types such as