-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON schema validation passes when it shouldn't #465
Comments
The problem lies within the This schema will pass validation on any given file. {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"custom-properties": {
"patternProperties": {
"^x_.": {
"title": "custom property"
}
}
}
},
"type": "object",
"properties": {
"default": {
"type": "string"
}
},
"required": ["default"],
"additionalProperties": false,
"$ref": "#/definitions/custom-properties"
} when tested with check-jsonschema. I wonder if it is the same when tested with other validators. However, this schema works as expected: {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"default": {
"type": "string"
}
},
"required": ["default"],
"additionalProperties": false,
"patternProperties": {
"^x_.": {
"title": "custom property"
}
}
} |
Quoting from this page:
If I am reading this right, it means we cannot use |
Wow, this JSON schema thing is so ugly...... I believe we should be using "items": {
"allOf": [
{ "$ref": "#/$defs/argument" },
{ "$ref": "#/$defs/custom-properties" }
]
} as hinted by this SO page, but I was unable to make it work both for inner elements (argument) and root. If needed, I can make a much simpler YAML template that can be converted to JSON without using |
One thing that I found out that is working, is to remove the definition of the Should I do it? |
I was thinking about creating something like a JSON schema generator from YAML. I guess it's a good take, but it should be a separate project that can be incorporated in this one. |
Or we can use |
This is easily done. I have already tried it with
I was unable to make it work for the root element.
The quote I pasted about |
Quote from this page. But the following YAML for some reason is still not valid: aa: 1
default: a for: {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"custom-properties": {
"patternProperties": {
"^x_.": {
"title": "custom property"
}
}
}
},
"type": "object",
"properties": {
"default": {
"type": "string"
}
},
"required": ["default"],
"additionalProperties": false,
"$ref": "#/definitions/custom-properties"
} |
I am not sure, we can try to use this validator to match VS Code editor behavior as much as possible. Maybe I am wrong, but I guess VS Code extension supports more than draft 7 according to its behavior. P.S. To set up Go, this action can be used.
Yeah, I wanna see it. ;) |
👉 #468 |
Matching to VS Code validation is in no way a priority for me. Our schema should simply be standards compliant. If VS code validation works as intended (i.e., it FAILS when there are arbitrary values that do not start with I tested
Test YAML: default: asd
x_root: asd
asd: asd
args:
- name: asd
x_asd: 1 |
It appears that our
bashly.json
schema allows invalid value types to pass as valid.The below is how it should behave:
Schema
Test file
Result
Fails as expected when running this command:
(this test was done to rule out check-jsonschema as the culprit)
However, when using disallowed value types in
bashly.yml
, the validation passes:bashly.yml
Result
In fact, anything I use seem to pass validation, even this
bashly.yml
The text was updated successfully, but these errors were encountered: