fixed Enum issue on schema.enum value#1083
fixed Enum issue on schema.enum value#1083msivasubramaniaan wants to merge 2 commits intoredhat-developer:mainfrom
Conversation
Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
|
This causes a regression: In VS Code, add this to settings.json: {
"yaml.schemas": {
"https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.32.1-standalone-strict/all.json": "*.k8s.yaml"
}
}Then, create a file apiVersion: v1
kind: Pod
metadata:
resourceVersion: test
|
There was a problem hiding this comment.
IMHO, the root of this issue is actually this location:
yaml-language-server/src/languageservice/parser/jsonParser07.ts
Lines 504 to 509 in e6165e4
which returns a boolean value as a string ("true" or "false"), since node.source is of type string.
I am not sure, why it is that way and returning node.value (which would be of the right type boolean) as is done above for null, number, and string?
| let enumValueMatch = false; | ||
| for (const e of schema.enum) { | ||
| if (val === e || isAutoCompleteEqualMaybe(callFromAutoComplete, node, val, e)) { | ||
| if (equals(val, schema.enum, node.type) || isAutoCompleteEqualMaybe(callFromAutoComplete, node, val, e)) { |
There was a problem hiding this comment.
I think this is wrong and should be:
| if (equals(val, schema.enum, node.type) || isAutoCompleteEqualMaybe(callFromAutoComplete, node, val, e)) { | |
| if (equals(val, e, node.type) || isAutoCompleteEqualMaybe(callFromAutoComplete, node, val, e)) { |
| } | ||
| } | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Adding this array handling for a boolean is not the right thing to add here.
Iterating over the enum values should be done at the caller site (see my other comment).
|
I still think, this is the more appropriate fix: #1080 |
What does this PR do?
This PR fix the schema.enum value on array element
What issues does this PR fix or reference?
#1078
Is it tested? How?
Yes. Added test case