redhat-developer / redhat-developer/vscode-yaml
All possible keys are incorrectly shown on conditional schema
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 829
- Forks
- 260
- Avg merge
- 5h 43m
- Merged PRs (30d)
- 1
Description
Describe the bug
I am trying to build a schema in which, conditional upon the value of a given key, a schema object is extended.
Here is an example of roughly working schema
{
"type": "object",
"properties": {
"typed_config": {
"type": "object",
"allOf": [
{
"properties": {
"schematype": {
"type": "string",
"enum": [
"type1.schema",
"type2.schema"
]
}
}
},
{"oneOf": [
{
"if": {
"properties": {
"schematype": { "const": "type1.schema"}
}
},
"then": {
"properties": {
"extra1": {
"type": "string"
}
}
},
"else": {"not": {}}
},
{
"if": {
"properties": {
"schematype": { "const": "type2.schema"}
}
},
"then": {
"properties": {
"extra2": {
"type": "string"
}
}
},
"else": {"not": {}}
}
]}
]
}
}
}
in this case the user fills the schematype and according to whether they set this to type1.schema or type2.schema an additional property (extra1/extra2 in this case) is added
this schema works once the user has set schematype - only extra1 or extra2 is shown

however, before the user has set the schematype both extra1 and extra2 are shown, even tho they should not be.

Expected Behavior
conditional schema should only be shown once the condition is met
Current Behavior
conditional schema is shown when the conditional property has not been set
Steps to Reproduce
- set above schema
- add
typed_configand autocomplete for values
Environment
- Windows
- Mac
- Linux
- other (please specify)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the supplied conditional schema in a Linux VS Code environment and compare completion before and after setting schematype. Trace the schema-completion entry point that handles if/then/else and add coverage for the unset-condition case. Done means extra1 and extra2 are not both suggested before schematype is set, while the matching property appears afterward.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, yaml
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100