Open hipstersmoothie opened 6 years ago
Here is another case where I am only suggested object and array when i expect: object, string, and array:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"expressions": {
"oneOf": [
{
"type": "object"
},
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
}
}
+1
+1
I have the same problem.
Steps to Reproduce:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["chains"],
"properties": {
"chains": {
"oneOf": [
{
"type": "array",
"items": {
"$ref": "chain.json"
}
},
{
"type": "array",
"items": {
"properties": {
"chain_path": {
"type": "string"
}
}
}
}
]
}
}
}
{
"$schema": "the_schema.json",
"chains": [
{
""
}
]
}
Does this issue occur when all extensions are disabled?: Yes
thnx.
+1
Same problem here.
+1
+1 It's about time to get an actual fix isn't it? It has been a loooong time since issue got opened
+1
Hey guys +1
s are generally considered bad form on an issue. Please react to the first comment instead which will also help with prioritizing. On most project's maintainers will go through all the +1
comments and hide them, as they do not contribute to the conversation around the issue
Hi folks. I've noticed this same issue lately and was about to file an issue myself. I think this is a general property of the JSON parser and not so much a VS code issue actually. When listing available options, properties with a "required" list aren't possible since those required fields aren't already entered. It's very chicken & egg. I'll delve into the code myself to see if I can whip up a workaround to include partial options but this may be a limitation of the JSON parsers.
Hello all! I am working on the fix and have some progress:
@jboero
When listing available options, properties with a "required" list aren't possible since those required fields aren't already entered. It's very chicken & egg.
Makes sense. That is my suggestion of logic:
The fix for the issue seems more complicated than I thought.
The problem is in validate
function that not only validates the schema for the JSON, but also returns matching subschemas. If there is a required field in one of your subschemas, but your node is empty (as in first comment of this issue thread), then the subschema is not valid and it's not added to matches.
When the user only starts writing the JSON using the schema, it's completely ok that JSON is not valid and IMHO VSCode should help users to complete the JSON.
A possible solution is to split validate
function in smaller parts, so it could be reused and make another function that returns matching subschemas but ignoring some validation problems. But that's a big work as far as I see 🙂
any more progress here?
still waiting for the fix
any more progress plz?
Steps to Reproduce:
NOTE: if i make "id" also required I get the correct suggestions.
Does this issue occur when all extensions are disabled?: Yes/No Yes