Pax8API/Private/Get-Pax8RemoteSpecManifest.ps1
|
function Get-Pax8RemoteSpecManifest { [CmdletBinding()] param ( [string[]]$SpecFile ) if (-not $SpecFile -or $SpecFile.Count -eq 0) { $SpecFile = @( 'authentication.json', 'partner-endpoints.json', 'quoting-endpoints.json', 'vendor-provisioning-endpoints.json', 'vendor-usage-endpoints.json', 'webhooks-api.json' ) } $specs = foreach ($name in $SpecFile) { $uri = "https://devx.pax8.com/openapi/$name" $response = Invoke-WebRequest -Uri $uri -UseBasicParsing -TimeoutSec 30 $bytes = [System.Text.Encoding]::UTF8.GetBytes([string]$response.Content) $stream = [System.IO.MemoryStream]::new($bytes) try { $hash = (Get-FileHash -InputStream $stream -Algorithm SHA256).Hash.ToLowerInvariant() } finally { $stream.Dispose() } $json = $response.Content | ConvertFrom-Json [pscustomobject]@{ file = $name url = $uri sha256 = $hash bytes = $bytes.Length title = [string]$json.info.title version = [string]$json.info.version pathCount = ($json.paths.PSObject.Properties | Measure-Object).Count operationCount = (($json.paths.PSObject.Properties.Value | ForEach-Object { $_.PSObject.Properties.Name }) | Where-Object { $_ -in @('get', 'post', 'put', 'patch', 'delete') } | Measure-Object).Count } } [pscustomobject]@{ checkedAt = [datetimeoffset]::UtcNow.ToString('o') source = 'https://devx.pax8.com/openapi' specs = @($specs) } } |