-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V1 #290
Conversation
This file contains 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
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`
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 changeconst
toenum
) - Useconst
instead of single-valuedenum
#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