schemars
schemars copied to clipboard
V1
Still to do:
- [x] Where we currently use a single-valued
enum, instead useconst(check which schema versions supportconst- may require a new visitor to changeconsttoenum) - #291 - [ ] Ensure compile times are OK for deriving
JsonSchemaon large types. Potentially reduce usages ofjson!/json_schema!for better performance, particularly in schemars_derive - [x] Review doc comments
- [x] Update documentation
- [ ] Review the behaviour of
with/schema_withon enum variants - I think the current behaviour is inconsistent with how serde performs (de)serialization - [x] move private
Schema::flattenfunction to_private - [x]
flattenhas 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 - [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()toalways_inline()? - [x] Maybe change
JsonSchema::schema_name()to return aCow<'static, str>instead of always an ownedString? - [x] Use
$defsinstead ofdefinitionsdepending on json schema version - [x] Consider re-adding something like the
preserve_orderfeature 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
definitionsor$defs(e.g. in openapi3)?
Breaking changes (so far):
- Methods that were deprecated are now removed
Schemais now defined as a wrapper around aserde_json::Value(which must be aValue::BoolorValue::Object), rather than a struct with a field for each JSON schema keyword (with some intermediary types).Schemais now available asschemars::Schemainstead ofschemars::schema::Schema, and all other types that were in theschemars::schemamodule have now been removed- functions that previously returned a
RootSchemanow just return aSchema
- functions that previously returned a
- schemars no longer has its own
Map/Settype aliases- The
SchemaGenerator.definitionsfield is now aserde_json::Map<String, serde_json::Value>(ideally it would be some sort ofMap<String, Schema>, butserde_json::Maponly really works with a plainValue)
- The
- The
impl_json_schemafeature flag has been removed -JsonSchemais now always implemented onSchema JsonSchema::schema_name()now returnsCow<'static, str>instead ofStringJsonSchema::is_referenceable()has been removed, and replaced withJsonSchema::always_inline()which should returns the opposite value- All optional dependencies are now suffixed by their version:
chronois nowchrono04eitheris noweither1smallvecis nowsmallvec1urlis nowurl2bytesis nowbytes1rust_decimalis nowrust_decimal1enumsetis nowenumset1smol_stris nowsmol_str02semveris nowsemver1indexmap,uuid08,arrayvec05andbigdecimal03have been removedindexmap2,arrayvec07andbigdecimal04are unchanged
- Remove functions
visit_schema_objectandvisit_root-schemafrom theVisitortrait - Remove the
retain_examplesfield fromSetSingleExample, which is now a unit struct