Skip to content
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

extend() doesn't copy applicable_validators #1125

Closed
PetrusAsikainen opened this issue Jul 12, 2023 · 1 comment
Closed

extend() doesn't copy applicable_validators #1125

PetrusAsikainen opened this issue Jul 12, 2023 · 1 comment
Labels
Bug Something doesn't work the way it should.

Comments

@PetrusAsikainen
Copy link

PetrusAsikainen commented Jul 12, 2023

It seems the applicable_validators property from c6b0fc4 never made it to extend.

This means that extending Draft4Validator (or other legacy validators) makes it consider properties next to $ref again. (This made connexion break OpenAPI 3.0 spec - spec-first/connexion#1721)

Steps to reproduce

import jsonschema

schema = {
  "$defs": { "test": { "type": "number" } },
  "$ref": "#/$defs/test",
  "maximum": 1
}

# no error, maximum is ignored as per spec
jsonschema.validate(schema=schema, instance=2, cls=jsonschema.Draft4Validator)

# extend() with no changes
BadValidator = jsonschema.validators.extend(jsonschema.Draft4Validator)

# jsonschema.exceptions.ValidationError: 2 is greater than the maximum of 1
jsonschema.validate(schema=schema, instance=2, cls=BadValidator)

Environment

$ python --version
Python 3.11.2
$ pip show jsonschema | grep Version
Version: 4.18.2
@Julian
Copy link
Member

Julian commented Jul 13, 2023

Should be released in just a bit in v4.18.3. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something doesn't work the way it should.
Projects
None yet
Development

No branches or pull requests

2 participants