PSRule-language.schema.json

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "PSRule language",
    "description": "A schema for PSRule YAML language files.",
    "oneOf": [
        {
            "$ref": "#/definitions/baseline"
        },
        {
            "$ref": "#/definitions/moduleConfig"
        }
    ],
    "definitions": {
        "resource-metadata": {
            "type": "object",
            "title": "Metadata",
            "description": "Additional information to identify the resource.",
            "properties": {
                "name": {
                    "type": "string",
                    "title": "Name",
                    "description": "The name of the resource. This must be unique.",
                    "minLength": 3
                },
                "annotations": {
                    "type": "object",
                    "title": "Annotations"
                }
            },
            "required": [
                "name"
            ]
        },
        "baseline": {
            "type": "object",
            "title": "Baseline",
            "description": "A PSRule Baseline.",
            "markdownDescription": "A PSRule Baseline. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Baseline.html)",
            "properties": {
                "kind": {
                    "type": "string",
                    "title": "Kind",
                    "description": "A PSRule Baseline resource.",
                    "markdownDescription": "A PSRule Baseline resource. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Baseline.html)",
                    "enum": [
                        "Baseline"
                    ]
                },
                "metadata": {
                    "type": "object",
                    "$ref": "#/definitions/resource-metadata"
                },
                "spec": {
                    "type": "object",
                    "$ref": "#/definitions/baselineSpec"
                }
            },
            "required": [
                "kind",
                "metadata",
                "spec"
            ],
            "additionalProperties": false
        },
        "baselineSpec": {
            "type": "object",
            "title": "Baseline",
            "description": "A specification for a baseline.",
            "markdownDescription": "A specification for a baseline. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Baseline.html)",
            "properties": {
                "binding": {
                    "$ref": "#/definitions/binding-option"
                },
                "configuration": {
                    "$ref": "#/definitions/configuration"
                },
                "rule": {
                    "type": "object",
                    "title": "Rule",
                    "description": "A filter for included or excluded rules.",
                    "properties": {
                        "include": {
                            "type": "array",
                            "title": "Include rules",
                            "description": "Rules to include by name in the baseline.",
                            "markdownDescription": "Rules to include by name in the baseline. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Options.html#ruleinclude)",
                            "$ref": "#/definitions/rule-names"
                        },
                        "exclude": {
                            "type": "array",
                            "title": "Exclude rules",
                            "description": "Rules to exclude by name from the baseline.",
                            "markdownDescription": "Rules to exclude by name from the baseline. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Options.html#ruleexclude)",
                            "$ref": "#/definitions/rule-names"
                        },
                        "tag": {
                            "type": "object",
                            "title": "Tags",
                            "description": "Require rules to have the following tags.",
                            "markdownDescription": "Require rules to have the following tags. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Options.html#ruletag)",
                            "additionalProperties": {
                                "oneOf": [
                                    {
                                        "type": "string",
                                        "description": "A required tag."
                                    },
                                    {
                                        "type": "array",
                                        "description": "A required tag.",
                                        "items": {
                                            "type": "string"
                                        },
                                        "uniqueItems": true
                                    }
                                ]
                            }
                        }
                    },
                    "additionalProperties": false
                }
            },
            "additionalProperties": false
        },
        "moduleConfig": {
            "type": "object",
            "title": "ModuleConfig",
            "description": "A PSRule ModuleConfig.",
            "properties": {
                "kind": {
                    "type": "string",
                    "title": "Kind",
                    "description": "A PSRule ModuleConfig resource.",
                    "enum": [
                        "ModuleConfig"
                    ]
                },
                "metadata": {
                    "type": "object",
                    "$ref": "#/definitions/resource-metadata"
                },
                "spec": {
                    "type": "object",
                    "$ref": "#/definitions/moduleConfigSpec"
                }
            },
            "required": [
                "kind",
                "metadata",
                "spec"
            ],
            "additionalProperties": false
        },
        "moduleConfigSpec": {
            "type": "object",
            "title": "ModuleConfig",
            "description": "A specification for a ModuleConfig.",
            "properties": {
                "binding": {
                    "$ref": "#/definitions/binding-option"
                },
                "configuration": {
                    "$ref": "#/definitions/configuration"
                },
                "convention": {
                    "$ref": "#/definitions/convention-option"
                },
                "output": {
                    "type": "object",
                    "title": "Output options",
                    "description": "Options that affect how output is generated.",
                    "properties": {
                        "culture": {
                            "type": "array",
                            "title": "Culture",
                            "description": "One or more cultures to use for generating output. When multiple cultures are specified, the first matching culture will be used. By default, the current PowerShell culture is used.",
                            "markdownDescription": "One or more cultures to use for generating output. When multiple cultures are specified, the first matching culture will be used. By default, the current PowerShell culture is used. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Options.html#outputculture)",
                            "items": {
                                "type": "string",
                                "description": "A culture for generating output.",
                                "minLength": 2
                            },
                            "uniqueItems": true,
                            "defaultSnippets": [
                                {
                                    "label": "en-AU",
                                    "bodyText": [
                                        "en-AU"
                                    ]
                                },
                                {
                                    "label": "en-US",
                                    "bodyText": [
                                        "en-US"
                                    ]
                                },
                                {
                                    "label": "en-GB",
                                    "bodyText": [
                                        "en-GB"
                                    ]
                                }
                            ]
                        }
                    },
                    "additionalProperties": false
                }
            },
            "additionalProperties": false
        },
        "rule-names": {
            "type": "array",
            "items": {
                "type": "string",
                "$ref": "#/definitions/rule-name"
            },
            "uniqueItems": true
        },
        "rule-name": {
            "type": "string",
            "minLength": 3
        },
        "binding-option": {
            "type": "object",
            "title": "Object binding",
            "description": "Configure property/ object binding options.",
            "properties": {
                "field": {
                    "type": "object",
                    "title": "Field",
                    "description": "Custom fields to bind.",
                    "markdownDescription": "Custom fields to bind. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Options.html#bindingfield)",
                    "additionalProperties": {
                        "type": "array",
                        "description": "A custom field to bind.",
                        "markdownDescription": "Custom field to bind. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Options.html#bindingfield)",
                        "items": {
                            "type": "string"
                        },
                        "uniqueItems": true
                    }
                },
                "ignoreCase": {
                    "type": "boolean",
                    "title": "Ignore case",
                    "description": "Determines if custom binding uses ignores case when matching properties. The default is true.",
                    "markdownDescription": "Determines if custom binding uses ignores case when matching properties. The default is `true`. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Options.html#bindingignorecase)",
                    "default": true
                },
                "nameSeparator": {
                    "type": "string",
                    "title": "Name separator",
                    "description": "Configures the separator to use for building a qualified name. The default is '/'.",
                    "markdownDescription": "Configures the separator to use for building a qualified name. The default is `/`. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Options.html#bindingnameseparator)",
                    "default": "/"
                },
                "targetName": {
                    "type": "array",
                    "title": "Bind TargetName",
                    "description": "Specifies one or more property names to bind TargetName to.",
                    "markdownDescription": "Specifies one or more property names to bind TargetName to. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Options.html#bindingtargetname)",
                    "items": {
                        "type": "string"
                    },
                    "uniqueItems": true
                },
                "targetType": {
                    "type": "array",
                    "title": "Bind TargetType",
                    "description": "Specifies one or more property names to bind TargetType to.",
                    "markdownDescription": "Specifies one or more property names to bind TargetType to. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Options.html#bindingtargettype)",
                    "items": {
                        "type": "string"
                    },
                    "uniqueItems": true
                },
                "useQualifiedName": {
                    "type": "boolean",
                    "title": "Use qualified name",
                    "description": "Determines if a qualified TargetName is used. The default is false.",
                    "markdownDescription": "Determines if a qualified TargetName is used. The default is `false`. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Options.html#bindingusequalifiedname)",
                    "default": false
                }
            },
            "additionalProperties": false
        },
        "configuration": {
            "type": "object",
            "title": "Configuration values",
            "description": "A set of key/ value configuration options for rules.",
            "markdownDescription": "A set of key/ value configuration options for rules. [See help](https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Options.html#configuration)",
            "defaultSnippets": [
                {
                    "label": "Configuration value",
                    "body": {
                        "${1:Key}": "${2:Value}"
                    }
                }
            ]
        },
        "convention-option": {
            "type": "object",
            "title": "Convention options",
            "description": "Options that configure conventions.",
            "properties": {
                "include": {
                    "type": "array",
                    "title": "Include conventions",
                    "description": "An ordered list of conventions to include.",
                    "items": {
                        "type": "string"
                    },
                    "uniqueItems": true
                }
            },
            "additionalProperties": false
        }
    }
}