Handle registration of schemas with the same $id
#60
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.
Raise a value error when attempting to register a schema with the same
$id
andversion
with another one that has already been registered.Also allow
register_schema_file
to accept a file object as input. Would be useful for loading client schemas imported usingimportlib.resources
which are returned as file objects.outdated stuff below
Currently if the input schema has the same
$id
and version as an existing schema, it would just override it. One situation where this is not ideal is the case of client events in jupyter-server/jupyter_server#364. A client can override and mimic a server event just by having the same$id
and version.This PR add a new argument
duplicate
toregister_schema_file
that takes one of the following values'raise'
: raise aValueError
when registering a schema having the same$id
with another schema that has already been registered'allow'
: If the input schema has the same$id
and version as another schema that has already been registered, it would override the existing schema. In case the input schema only has the same$id
as an existing schema but a different version, the input schema would be registered along side the existing schema.'skip'
: does nothingdefault is set to be
'raise'
which is the strictest option.