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
                }
            },
            "required": [
                "name"
            ]
        },
        "baseline": {
            "type": "object",
            "title": "Baseline",
            "description": "A PSRule Baseline.",
            "properties": {
                "kind": {
                    "type": "string",
                    "title": "Kind",
                    "description": "A PSRule Baseline resource.",
                    "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.",
            "properties": {
                "binding": {
                    "$ref": "#/definitions/bindingOption"
                },
                "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.",
                            "$ref": "#/definitions/rule-names"
                        },
                        "exclude": {
                            "type": "array",
                            "title": "Exclude rules",
                            "description": "Rules to exclude by name from the baseline.",
                            "$ref": "#/definitions/rule-names"
                        },
                        "tag": {
                            "type": "object",
                            "title": "Tags",
                            "description": "Require rules to have the following tags.",
                            "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/bindingOption"
                },
                "configuration": {
                    "$ref": "#/definitions/configuration"
                },
                "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.",
                            "items": {
                                "type": "string",
                                "description": "A culture for generating output.",
                                "minLength": 2
                            },
                            "uniqueItems": true
                        }
                    },
                    "additionalProperties": false
                }
            },
            "additionalProperties": false
        },
        "rule-names": {
            "type": "array",
            "items": {
                "type": "string",
                "$ref": "#/definitions/rule-name"
            },
            "uniqueItems": true
        },
        "rule-name": {
            "type": "string",
            "minLength": 3
        },
        "bindingOption": {
            "type": "object",
            "title": "Object binding",
            "description": "Configure property/ object binding options.",
            "properties": {
                "field": {
                    "type": "object",
                    "title": "Field",
                    "description": "Custom fields to bind.",
                    "additionalProperties": {
                        "type": "array",
                        "description": "A custom field to bind.",
                        "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.",
                    "default": true
                },
                "nameSeparator": {
                    "type": "string",
                    "title": "Name separator",
                    "description": "Configures the separator to use for building a qualified name. The default is '/'.",
                    "default": "/"
                },
                "targetName": {
                    "type": "array",
                    "title": "Bind TargetName",
                    "description": "Specifies one or more property names to bind TargetName to.",
                    "items": {
                        "type": "string"
                    },
                    "uniqueItems": true
                },
                "targetType": {
                    "type": "array",
                    "title": "Bind TargetType",
                    "description": "Specifies one or more property names to bind TargetType to.",
                    "items": {
                        "type": "string"
                    },
                    "uniqueItems": true
                },
                "useQualifiedName": {
                    "type": "boolean",
                    "title": "Use qualified name",
                    "description": "Determines if a qualified TargetName is used. The default is false.",
                    "default": false
                }
            },
            "additionalProperties": false
        },
        "configuration": {
            "type": "object",
            "title": "Configuration values",
            "description": "A set of key/ value configuration options for rules."
        }
    }
}