Tasks/Content/JSONSchema.ps1

<#
    .SYNOPSIS
    Validates JSON files against configured JSON schemas.

    .DESCRIPTION
    Uses configured JSON schema mappings to validate matching `.json` files
    under the build root with `Test-Json`.

    .GROUP
    Content

    .CONFIGURATION
    `Tasks.JSONSchema.Schemas` defines the JSON files and schema files to
    validate. Each mapping has a repository-relative `Path` pattern for matching
    JSON files and a `Schema` value for the schema file.

    Use `**/*.json` to match JSON files recursively.

    `Tasks.JSONSchema.Exclude` excludes matching files from this task.

    ### Example

    ```powershell
    . (Get-PlumberTaskLoader) -Config @{
        ModuleManifest = 'MyModule.psd1'
        Tasks = @{
            JSONSchema = @{
                Schemas = @(
                    @{
                        Path = 'Resource/*.json'
                        Schema = 'Resource/Schema/config.schema.json'
                    }
                )
                Exclude = @('Resource/Schema/*.json')
            }
        }
    }
    ```

    .RUN
    ```powershell
    Invoke-Plumber -Task JSONSchema
    ```

    .PASS
    ```json
    {
      "name": "Plumber",
      "enabled": true
    }
    ```

    .FAIL
    ```json
    {
      "enabled": true
    }
    ```
#>

Add-BuildTask -Name JSONSchema -Jobs { Invoke-PlumberJSONSchema }