Skip to content

extend() doesn't copy applicable_validators #1125

@PetrusAsikainen

Description

@PetrusAsikainen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething doesn't work the way it should.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions