Unless I'm being super stupid - conditional matching does not work in "if" blocks - all conditions seem to be ignored and the else block always executes.
If an "if"'s condition evaluates to true, it should match the then schema
The else schema is always evaluated.
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "http://example.com/example.json",
"type": "object",
"title": "The root schema",
"description": "The root schema comprises the entire JSON document.",
"default": [],
"properties": {
"name": {
"type": "string",
},
"var": {
"type": "string",
}
},
"if": {
"properties": {
"var": {
"type": "string"
}
}
},
"then": {
"required": [
"pineapple"
]
},
"else": {
"required": [
"tomato"
]
},
"additionalProperties": true
}
name: aName
var: something
inputs:
var is quite clearly a string type.Although this is using JSON - the data is a YAML to JSON conversion - the schema holds true and requires pineapple here https://jsonschema.dev/s/PaRXa
I just narrowed down odd behavior to the same issue. In my case I use a pattern that begins with
"allOf": [
{
"$ref": "#/definitions/type"
},
{
"if": {
"properties": {
"type": {
"const": "metadata-registry"
}
}
},
"then": {
"$ref": "#/definitions/metadata"
}
},
to select definitions based on a type key in the YAML file. None of them are being selected. This did work on previous versions of the extension (before 0.12.0)
Should be fixed with https://github.com/redhat-developer/yaml-language-server/pull/357
Many thanks for such a fast turnaround! How/when will the update from the language server be picked up by this extension?
I start release process, I hope to finish in a few hours.
Most helpful comment
I start release process, I hope to finish in a few hours.