Skip to content
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 fails when additionalItems with oneOf and $ref is used. #75394

Closed
HIAB-vesteel opened this issue Jun 13, 2019 · 1 comment · Fixed by microsoft/vscode-json-languageservice#69
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug json JSON support issues verified Verification succeeded
Milestone

Comments

@HIAB-vesteel
Copy link

When having a schema with additionalItems containing oneOf with $ref the schema gives errors (see comments in input_data.json). When removing $ref and pasting in the schemas validation works as intended.

  • VSCode Version: 1.35.1
  • OS Version: Windows 10 64-big

Steps to Reproduce:

  1. Add files (see below) to empty project
  2. See it fail

input_data.json

{
  "$schema": "./BasicType.schema.json",
  "extra_types": [
    {
      "type": "Type_A"
    },
    {
      "type": "Type_B",
      "false_property": "Gives error"
    },
    {
      "type": "Type_B" // Matching multiple schemas
    },
    {
      "type": "Type_A"  // Matching multiple schemas
    },
    {
      "type": "Type_B",  // Matching multiple schemas
      "false_property": "Should also give error"
    }
  ]
}

BasicType.schema.json

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "required": [
        "$schema",
        "extra_types"
    ],
    "properties": {
        "$schema": {
            "type": "string"
        },
        "extra_types": {
            "type": "array",
            "items": [
                {
                    "$ref": "./Type_A.schema.json"
                },
                {
                    "$ref": "./Type_B.schema.json"
                }
            ],
            "additionalItems": {
                "oneOf": [
                    {
                        "$ref": "./Type_A.schema.json"
                    },
                    {
                        "$ref": "./Type_B.schema.json"
                    }
                ]
            },
            "minItems": 2
        }
    },
    "additionalProperties": false
}

Type_A.schema.json

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "required": [
        "type"
    ],
    "properties": {
        "type": {
            "type": "string",
            "const": "Type_A"
        }
    },
    "additionalProperties": false
}

Type_B.schema.json

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "required": [
        "type"
    ],
    "properties": {
        "type": {
            "type": "string",
            "const": "Type_B"
        }
    },
    "additionalProperties": false
}
@vscodebot
Copy link

vscodebot bot commented Jun 13, 2019

@aeschli aeschli added json JSON support issues bug Issue identified by VS Code Team member as probable bug and removed new release labels Jun 14, 2019
@aeschli aeschli added this to the Backlog milestone Jun 14, 2019
@aeschli aeschli modified the milestones: Backlog, August 2020 Aug 31, 2020
@aeschli aeschli added the verified Verification succeeded label Sep 3, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug json JSON support issues verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants