Public/Get-DattoApiSpecification.ps1
|
function Get-DattoApiSpecification { <# .SYNOPSIS Returns the complete bundled Datto OpenAPI specification. .DESCRIPTION Returns the complete OpenAPI document supplied with the module, including top-level information, servers, tags, security, security schemes, reusable parameters, schemas, responses, and every path operation. Object mode returns a parsed PowerShell object. JSON and YAML modes return the exact bundled text. .PARAMETER Format Object, Json, or Yaml. .EXAMPLE $openApi = Get-DattoApiSpecification $openApi.info .EXAMPLE Get-DattoApiSpecification -Format Yaml | Set-Content .\DattoAPI.openapi.yaml -Encoding UTF8 .OUTPUTS PSCustomObject or System.String #> [CmdletBinding()] param( [Parameter()] [ValidateSet('Object', 'Json', 'Yaml')] [string]$Format = 'Object' ) switch ($Format) { 'Object' { return (Get-DattoApiSpecificationDocument) } 'Json' { $path = Join-Path -Path $script:DattoApiModuleRoot -ChildPath 'spec/DattoAPI.openapi.json' return (Get-Content -LiteralPath $path -Raw -Encoding UTF8) } 'Yaml' { $path = Join-Path -Path $script:DattoApiModuleRoot -ChildPath 'spec/DattoAPI.openapi.yaml' return (Get-Content -LiteralPath $path -Raw -Encoding UTF8) } } } |