Skip to content

"$schema" in schema itself is not ignored #58

@fabb

Description

@fabb

When the schema itself contains a key "$schema": "https://json-schema.org/draft/2020-12/schema", this is thrown as an error.

Reproduction:

it('should succeed', () => {
    const schema = {
        $id: 'https://my-schema.org/SomeObject.json',
        $schema: 'https://json-schema.org/draft/2020-12/schema',
        title: 'Some title',
        description: 'Some description',
        type: 'object',
        additionalProperties: true,
        properties: {
            id: {
                description: 'An id',
                type: 'string',
            },
        },
    }

    expect({
        $schema: 'https://my-schema.org/SomeObject.json',
        id: 'some id',
    }).toMatchSchema(schema)
})

Expected

The unit test should succeed

Actual

The unit test fails with this error:

    no schema with key or ref "https://json-schema.org/draft/2020-12/schema"

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