schemars icon indicating copy to clipboard operation
schemars copied to clipboard

V1

Open GREsau opened this issue 1 year ago • 0 comments

Still to do:

  • [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
  • [ ] 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 functions visit_schema_object and visit_root-schema from the Visitor trait
  • Remove the retain_examples field from SetSingleExample, which is now a unit struct

GREsau avatar May 12 '24 18:05 GREsau