JSON Schema autocompletion if/then/else array of objects properties
Hello,
I have the following scenario:
main.json:
```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"strategies": {
"type": "array",
"items": {
"allOf": [
{
"if": {
"properties": { "type": { "const": "line" } }
},
"then": {
"$ref": "strategy-line.json"
}
},
{
"if": {
"properties": { "type": { "const": "node" } }
},
"then": {
"$ref": "strategy-node.json"
}
}
]
}
}
}
}
```
strategy-line.json:
```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"type": {
"const": "line"
},
"line": {
"type": "string"
},
"lineNumber": {
"type": "integer"
},
"file": {
"type": "string"
},
"directory": {
"type": "string"
}
},
"required": [
"type",
"line",
"lineNumber",
"file"
]
}
```
strategy-node.json:
```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"type": {
"const": "node"
},
"directory": {
"type": "string"
}
},
"required": [
"type"
]
}
```
Is that a PHPStorm issue or is something wrong with the JSON-Schema?
The validation works btw:
Please sign in to leave a comment.
Where do you test this? Could you please attach a code/file?
I've been playing with similar JSON Schemas and I have the same problem.
Here is the schema I am working with
And here is an example test json for it.
The validation is correct saying that there is a missing property `topics` or `topicPattern`. However, when you have the caret at `<caret>` it only suggests properties from the main schema definition. Does not suggest `topics`, `topicPattern`, `groupId`, `clientIdPrefix` etc.
If you change the `type` to `jms` there should be another missing property (`destination`) and other suggested properties.
Is this expected or is this in an issue?
This can easily be tested by adding the schema json from here as a manual Schema file and match the pattern for the example json. For example create the example in `example.channel` and use file pattern `*.channel`
I forgot to mention I am using IntelliJ IDEA. More specifically:
IntelliJ IDEA 2020.1 EAP (Ultimate Edition)
Build #IU-201.6251.22, built on March 12, 2020
Is there an update on this?
As said above, validation works properly but redirection into schema when clicking on those attributes or searches for new suggestions doesn't. Thanks in advances.
IntelliJ IDEA 2020.3 (Community Edition)
Build #IC-203.5981.155, built on November 30, 2020
It's a known issue unfortunately, please follow https://youtrack.jetbrains.com/issue/WEB-48859 for updates