Skip to content

Documentation is out to date #1251

Closed
Closed
@pbordron

Description

@pbordron

I wanted to load some schemas in memory, but got following errors when reproducing the example:

  • ImportError: cannot import name 'DRAFT2020212' from 'referencing.jsonschema' for
from referencing import Registry, Resource
from referencing.jsonschema import DRAFT2020212
schema = DRAFT202012.create_resource({"type": "integer", "minimum": 0})
registry = Registry().with_resources(
    [
        ("http://example.com/nonneg-int-schema", schema),
        ("urn:nonneg-integer-schema", schema),
    ],
)
  • TypeError: create.<locals>.Validator.__init__() got an unexpected keyword argument 'registry' for
from jsonschema import Draft202012Validator
validator = Draft202012Validator(
    {
        "type": "object",
        "additionalProperties": {"$ref": "urn:nonneg-integer-schema"},
    },
    registry=registry,  # the critical argument, our registry from above
)
validator.validate({"foo": 37})
validator.validate({"foo": -37})  # Uh oh!

I didn't test other examples, but they might be also wrong.

Could you update the documentation to reflect current version of jsonschema?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions