Conversation
No longer use it for internally-tagged enums. Instead, use a private helper that adds the tag property.
…ts`, regenerate test schemas
…n a schema's `properties`
This also changes the strategy for running visitors on subschemas - it is now done eagerly, as soon as they're added to the definitions map.
…efinitions` lazily (only if/when root schema is created). Visitors will now always descend into `$defs`/`definitions`. If a generator is configured to use a different definitions path, then the visitor will also descend into that path (but a plain `Visitor` would NOT.
Since it's now the only method, there's no good reason to implement the trait without implementing that method.
I'm reasonably satisfied that the current behaviour of enum variants with `with`/`schema_with` attributes is correct
This means `SchemaSettings` and `SchemaGenerator` are both now `Send`
This allows running arbitrary transforms on generated schemas when deriving `JsonSchema`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Still to do:
enum, instead useconst(check which schema versions supportconst- may require a new visitor to changeconsttoenum) - Useconstinstead of single-valuedenum#291JsonSchemaon large types. Potentially reduce usages ofjson!/json_schema!for better performance, particularly in schemars_derivewith/schema_withon enum variants - I think the current behaviour is inconsistent with how serde performs (de)serializationSchema::flattenfunction to_privateflattenhas 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_fieldsTempFixupForTestsopenapi3, 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?$defsinstead ofdefinitionsdepending on json schema versionpreserve_orderfeature flag to preserve field order in schemasdefinitionsor$defs(e.g. in openapi3)?Breaking changes (so far):
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 removedRootSchemanow just return aSchemaMap/Settype aliasesSchemaGenerator.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)impl_json_schemafeature flag has been removed -JsonSchemais now always implemented onSchemaJsonSchema::schema_name()now returnsCow<'static, str>instead ofStringJsonSchema::is_referenceable()has been removed, and replaced withJsonSchema::always_inline()which should returns the opposite valuechronois nowchrono04eitheris noweither1smallvecis nowsmallvec1urlis nowurl2bytesis nowbytes1rust_decimalis nowrust_decimal1enumsetis nowenumset1smol_stris nowsmol_str02semveris nowsemver1indexmap,uuid08,arrayvec05andbigdecimal03have been removedindexmap2,arrayvec07andbigdecimal04are unchangedretain_examplesfield fromSetSingleExample, which is now a unit structdescriptionvisitmodule andVisitortrait have been replace withtransformandTransformrespectively. Accordingly, these items have been renamed:SchemaSettings::visitors->SchemaSettings::transformsSchemaSettings::with_visitor->SchemaSettings::with_transformSchemaGenerator::visitors_mut->SchemaGenerator::transforms_mutGenVisitor->GenTransformVisitor::visit_schema->Transform::transformvisit_schema_objectandvisit_root_schemamethods have been removedvisit::visit_schema->transform::transform_subschemasvisit_schema_objectandvisit_root_schemafunctions have been removed