'JSON schema - reference dynamic property names in array

I would like to validate (and autocomplete) values in an array against properties of an object.

Consider this data example:

{
   "scripts": {
      "prepare": { "command": "./prepare.sh" },
      "buildSrc": { "command": "./build-src.sh" },
      "buildDocs": { "command": "./build-docs.sh" },
      "publish": { "command": "./publish.sh" }
   },
   "pipelines": {
      "buildProd": ["prepare", "buildSrc", "buildDocs", "publish"],
      "buildDev": ["prepare", "buildSrc"]
   }
}

The properties of the scripts object can be named whatever you want and I need the values of the arrays of the properties in pipelines to match against the properties of scripts. I.e. it should show an error if you reference a script which hasn't been defined. (And preferably get editors to suggest existing names from the scripts object.)

Is this something that's possible to define in JSON Schemas?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source