Vscode-yaml: Schema validation reports errors in valid YAML document

Created on 2 Nov 2017  路  8Comments  路  Source: redhat-developer/vscode-yaml

I have rather complex JSON schema with which YAML plugin doesn't work correctly. It reports errors in valid YAML document. But when I use this schema with equivalent JSON document it works correctly.

I tried to simplify the schema and narrow the problem but it is still long and complex because the problem is in some combination of schema constructs.

I have vscode-yaml 0.0.4 with VSCode insider build (see bellow).

Here is the YAML document which doesn't work correctly:

aaa:
  type: TypeA
  properties:
    propertyA: { stringArray: [ "abcd"] }

Here is JSON document which works:

{
    "$schema": "./test.schema.json",
    "aaa": {
        "type": "TypeA",
        "properties": {
            "propertyA": {
                "stringArray": ["abcd"]
            }
        }
    }
}

Here is test.schema.json schema:

{
  "$schema": "http://json-schema.org/schema#",
  "type": "object",
  "properties": {
    "aaa": {
      "oneOf": [
        {
          "allOf": [
            {
              "properties": {
                "type": {
                  "enum": [
                    "TypeA"
                  ]
                },
                "properties": {
                  "type": "object",
                  "properties": {
                    "propertyA": {
                      "$ref": "#/definitions/commonStructures",
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "propertyA"
                  ],
                  "additionalProperties": true
                }
              },
              "required": [
                "type"
              ]
            },
            {
              "$ref": "#/definitions/commonProperties"
            }
          ]
        },
        {
          "allOf": [
            {
              "properties": {
                "type": {
                  "enum": [
                    "TypeB"
                  ]
                },
                "properties": {
                  "type": "object",
                  "properties": {
                    "propertyB": {
                      "$ref": "#/definitions/commonStructures",
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "propertyB"
                  ],
                  "additionalProperties": true
                }
              },
              "required": [
                "type"
              ]
            },
            {
              "$ref": "#/definitions/commonProperties"
            }
          ]
        }
      ]
    }
  },
  "required": [
    "aaa"
  ],
  "additionalProperties": true,
  "definitions": {
    "commonProperties": {
      "type": "object",
      "properties": {
        "commonProperty": {
          "type": "string"
        }
      }
    },
    "commonStructures": {
      "type": "object",
      "properties": {
        "stringArray": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        }
      },
      "additionalProperties": false
    }
  }
}
  • VSCode Version: Code - Insiders 1.18.0-insider (2ab10d50163f008ada9a4aa215de8c884857ce99, 2017-11-01T05:19:21.302Z)
  • OS Version: Windows_NT x64 10.0.16299
  • Extensions:

Extension|Author (truncated)|Version
---|---|---
vscode-yaml|red|0.0.4

bug

All 8 comments

I've narrowed this down to a regression in redhat-developer/yaml-language-server@2a8456a7e2e319aece0f9d05e5af087450cedf63 inside the jsonParser. I'm currently working on fixing this!

I think I'm meeting the same issue. I have a schema for a .travis.yml that defines the type of e.g. before_install as oneOf boolean, string or array of strings:

https://github.com/felixfbecker/schemastore/blob/2a32ed0e3eab265b9a82f0b2dbcd1046eab85bde/src/schemas/json/travis.json#L15-L28

But the inside VS Code I get the validation error that boolean is expected (and not string array):

image

https://github.com/aaronpowell/ps-nvmw/blob/9784e5ada938a7485a6786371ac76b3ed78d37fb/.travis.yml#L13

I believe this is the same issue. I have a fix for it we just need to release the extension again for the update!

@JPinkney to make these releases automatic, would you be interested in a semantic-release auto-release workflow? I set that up for php-language-server and vscode-php-intellisense and it works very well

Hi, I've fixed this issue! It's now available in the latest release!

@JPinkney awesome! Did you read my comment above?

@JPinkney thanks, with latest release my schema works as expected.

BTW the schema is here: https://github.com/vojtechhabarta/heat-template-schema/blob/master/schema/heat-template.schema.json - it is generated schema for OpenStack Heat Orchestration Templates.

@vojtechhabarta I would encourage you to contribute it to jsonschemastore :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sheeeng picture sheeeng  路  7Comments

Deilan picture Deilan  路  6Comments

shadowzen1978 picture shadowzen1978  路  7Comments

teresaejunior picture teresaejunior  路  4Comments

rylnd picture rylnd  路  3Comments