Skip to content

Deprecated matching string pattern inside anyOf is not considered a match #304

@Jklein64

Description

@Jklein64

The following schemas should produce the same output on the test.json file:

test1.schema.json:

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
        "key": {
            "anyOf": [
                {
                    "type": "string",
                    "const": "unused literal"
                },
                {
                    "type": "string",
                    "const": "text value",
                    "deprecated": true
                }
            ]
        }
    }
}

test2.schema.json:

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
        "key": {
            "anyOf": [
                {
                    "type": "string",
                    "const": "unused literal"
                },
                {
                    "type": "string",
                    "pattern": "^text value$",
                    "deprecated": true
                }
            ]
        }
    }
}

test.json:

{
    "key": "text value"
}

However, using test2.schema.json shows Value is not accepted. Valid values: "unused literal". on hover instead of the expected Value is deprecated that it shows for test1.schema.json.

Image

This means that the text "text value" did not match the pattern "^text value$", which it should... (and does when "deprecated": true is removed)

Note that this example seems to be minimal: removing the non-deprecated branch of the anyOf leads to different (and correct) results, for example

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