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

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

Open
fabb opened this issue Jul 7, 2023 · 0 comments
Open

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

fabb opened this issue Jul 7, 2023 · 0 comments

Comments

@fabb
Copy link

fabb commented Jul 7, 2023

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant