Schema Validation

Schema Validation

Enabling schema validation in VSCode:

.vscode/settings.json
    "yaml.schemas": {
        "https://raw.githubusercontent.com/noxsios/vai/main/vai.schema.json": "vai.yaml",
    },

Per file basis:

some-task.yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/noxsios/vai/main/vai.schema.json

Raw Schema

vai.schema.json
{
   "$defs": {
     "Step": {
       "additionalProperties": false,
       "oneOf": [
         {
           "properties": {
             "eval": {
               "not": true
             },
             "run": {
               "type": "string"
             },
             "uses": {
               "not": true
             }
           },
           "required": [
             "run"
           ]
         },
         {
           "properties": {
             "eval": {
               "not": true
             },
             "run": {
               "not": true
             },
             "uses": {
               "type": "string"
             }
           },
           "required": [
             "uses"
           ]
         },
         {
           "properties": {
             "eval": {
               "type": "string"
             },
             "run": {
               "not": true
             },
             "uses": {
               "not": true
             }
           },
           "required": [
             "eval"
           ]
         }
       ],
       "properties": {
         "eval": {
           "description": "Expression to evaluate with tengo",
           "type": "string"
         },
         "id": {
           "description": "Unique identifier for the step",
           "type": "string"
         },
         "name": {
           "description": "Human-readable name for the step",
           "type": "string"
         },
         "run": {
           "description": "Command/script to run",
           "type": "string"
         },
         "uses": {
           "description": "Location of a remote task to call conforming to the purl spec",
           "type": "string"
         },
         "with": {
           "additionalProperties": false,
           "description": "Additional parameters for the step/task call",
           "minItems": 1,
           "patternProperties": {
             "^[a-zA-Z_]+[a-zA-Z0-9_]*$": {
               "oneOf": [
                 {
                   "type": "string"
                 },
                 {
                   "type": "boolean"
                 },
                 {
                   "type": "integer"
                 }
               ]
             }
           },
           "type": "object"
         }
       },
       "type": "object"
     },
     "Task": {
       "items": {
         "$ref": "#/$defs/Step"
       },
       "type": "array"
     },
     "With": {
       "type": "object"
     }
   },
   "$id": "https://raw.githubusercontent.com/Noxsios/vai/main/vai.schema.json",
   "$schema": "https://json-schema.org/draft/2020-12/schema",
   "additionalProperties": false,
   "patternProperties": {
     "^[_a-zA-Z][a-zA-Z0-9_-]*$": {
       "$ref": "#/$defs/Task",
       "description": "Name of the task"
     }
   },
   "type": "object"
 }