Pax8API/Public/Update-Pax8GeneratedModule.ps1

function Update-Pax8GeneratedModule {
    [CmdletBinding(SupportsShouldProcess = $true)]
    param (
        [switch]$SkipDownload
    )

    $repoRoot = Resolve-Path (Join-Path $script:Pax8ModuleRoot '..\..')
    $updateSpec = Join-Path $repoRoot 'tools\Update-Pax8OpenApiSpec.ps1'
    $generator = Join-Path $repoRoot 'tools\New-Pax8ApiModule.ps1'

    if (-not (Test-Path -LiteralPath $generator)) {
        throw "Generator script was not found at '$generator'. Install from the full repository to regenerate the module."
    }

    if ($PSCmdlet.ShouldProcess($repoRoot, 'Regenerate Pax8API from OpenAPI specs')) {
        if (-not $SkipDownload) {
            if (-not (Test-Path -LiteralPath $updateSpec)) {
                throw "Spec updater script was not found at '$updateSpec'."
            }
            & $updateSpec | Out-Null
        }

        & $generator
    }
}