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:
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.

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
The following schemas should produce the same output on the
test.jsonfile: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.jsonshowsValue is not accepted. Valid values: "unused literal".on hover instead of the expectedValue is deprecatedthat it shows fortest1.schema.json.This means that the text
"text value"did not match the pattern"^text value$", which it should... (and does when"deprecated": trueis removed)Note that this example seems to be minimal: removing the non-deprecated branch of the
anyOfleads to different (and correct) results, for example