SchemaStore / schemastore

A collection of JSON schema files including full API
http://schemastore.org
Apache License 2.0
3.04k stars 1.67k forks source link

Error in Schema Test when there is a Map<string, any> property in the JSON file #3921

Closed WasiqB closed 2 months ago

WasiqB commented 2 months ago

Area with issue?

JSON Schema

✔️ Expected Behavior

I am creating JSON Schema for the config file for my open source Test Automation Framework, Boyka Framework.

There is one property called capabilities in the config file, which is a Map with String keys and it's value can be of any type, whether String, Number or Boolean.

I tried the following schema for capabilities:

{
  "capabilities": {
    "type": "object",
    "additionalProperties": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        }
      ]
    }
  }
}

This schema is just a part of the complete Config file schema.

I expect the schema test should pass.

❌ Actual Behavior

But the schema test is failing by giving the following message:

################ Error message
>> failed positive test | src/test/boyka-config/boyka-config.json
>> (Schema file) keywordLocation: #/properties/ui/properties/web/additionalProperties/properties/capabilities/additionalProperties/type
>> (Test file) instanceLocation:  /ui/web/test_lambda_test_chrome/capabilities/console
>> (Message)  must be string
>> Error in positive test.
##############################

YAML or JSON file that does not work.

{
  "$schema": "https://json.schemastore.org/boyka-config",
  "listeners_package": "io.github.boykaframework.testng.listeners",
  "ui": {
    "logging": {
      "exclude_logs": ["bugreport"]
    },
    "screenshot": {
      "enabled": true,
      "extension": "jpeg",
      "path": "./screenshots",
      "prefix": "SCR"
    },
    "timeout": {
      "explicit_wait": 30,
      "highlight_delay": 100,
      "implicit_wait": 10,
      "page_load_timeout": 30,
      "script_timeout": 10
    },
    "web": {
      "test_browserstack_chrome": {
        "base_url": "https://the-internet.herokuapp.com/",
        "browser": "REMOTE",
        "capabilities": {
          "browser": "Chrome",
          "browserVersion": "latest",
          "buildName": "Test BrowserStack Build",
          "debug": "true",
          "networkLogs": "true",
          "os": "Windows",
          "osVersion": "11",
          "projectName": "Test Boyka Project",
          "resolution": "1920x1080",
          "seleniumLogs": "true",
          "seleniumVersion": "4.8.0",
          "sessionName": "Test BrowserStack Session",
          "telemetryLogs": "true",
          "video": "true"
        },
        "password": "${env:BS_KEY}",
        "resize": "MAXIMIZED",
        "target": "BROWSER_STACK",
        "user_name": "${env:BS_USER}"
      },
      "test_lambda_test_chrome": {
        "base_url": "https://the-internet.herokuapp.com/",
        "browser": "REMOTE",
        "capabilities": {
          "browserName": "Chrome",
          "build": "Test LambdaTest Build",
          "console": true,
          "name": "Test LambdaTest Session",
          "network": true,
          "platform": "Windows 11",
          "resolution": "1920x1080",
          "version": "latest",
          "video": true,
          "visual": true
        },
        "password": "${env:LT_KEY}",
        "resize": "NORMAL",
        "target": "LAMBDA_TEST_WEB",
        "user_name": "${env:LT_USER}"
      },
      "test_local_chrome": {
        "base_url": "https://the-internet.herokuapp.com/",
        "browser": "CHROME",
        "browser_options": [
          "use-fake-device-for-media-stream",
          "use-fake-ui-for-media-stream"
        ],
        "custom_size": {
          "height": 1080,
          "width": 1580
        },
        "headless": true,
        "highlight": false,
        "page_load_strategy": "NORMAL",
        "resize": "CUSTOM"
      },
      "test_local_edge": {
        "base_url": "https://the-internet.herokuapp.com/",
        "browser": "EDGE",
        "resize": "FULL_SCREEN"
      },
      "test_local_firefox": {
        "browser": "FIREFOX"
      },
      "test_local_safari": {
        "browser": "SAFARI"
      },
      "test_selenium_grid": {
        "base_url": "https://the-internet.herokuapp.com/",
        "browser": "REMOTE",
        "capabilities": {
          "browserName": "chrome"
        },
        "port": "4444",
        "target": "LOCAL"
      }
    }
  }
}

IDE or code editor.

Visual Studio Code

Are you making a PR for this?

Yes, I will create a PR.

WasiqB commented 2 months ago

Working on PR #3922 when I encountered this issue.

WasiqB commented 2 months ago

The capabilities schema which I had used at one place, I missed using the same schema at other place. Once I updated this, my schema tests passed.

Closing this ticket now.