Pode
Pode copied to clipboard
Support for Response in YAML format
Feature
Add support for 3rd party YAML modules, and in the absence of any 3rd party, will use an internal YAML implementation. The internal YAML conversion implementation is limited in scope, and the performance is not good, like 3rd party solutions. The internal YAML module is primarily intended to be used to generate the OpenAPI definition in YAML format.
Note Pode has an external module to manage Yaml. But it's outdated.
New Functions
-
Write-PodeYamlResponse
The function will use the modulePSYaml
orpowershell-yaml
if imported otherwise, it will use the internal YAML conversion.
Impacted Functions
-
Enable-PodeOpenApi
-
-MarkupLanguage
Define the default markup language for the OpenApi spec ('Json', 'Json-Compress', 'Yaml')
-
Add-PodeRoute -PassThru -Method get -Path '/pet/findByStatus' -ScriptBlock {
#find the pet
Write-PodeYamlResponse -Value $myPets -StatusCode 200
} | Set-PodeOARouteInfo -Summary 'Finds Pets by status' -Description 'Multiple status values can be provided with comma separated strings' -Tags 'pet' -OperationId 'findPetsByStatus' -PassThru |
Set-PodeOARequest -PassThru -Parameters @( ( New-PodeOAStringProperty -Name 'status' -Description 'Status values that need to be considered for filter' -Default 'available' -Enum @('available', 'pending', 'sold') | ConvertTo-PodeOAParameter -In Query ) ) | Add-PodeOAResponse -StatusCode 200 -Description 'Successful operation' -Content (New-PodeOAContentMediaType -MediaType 'application/x-yaml' -Content 'Pet' -Array) -PassThru |
Add-PodeOAResponse -StatusCode 400 -Description 'Invalid status value'
I tried to revamp the old module unsuccessfully too many errors during the conversion of a complex OpenAPI document. I created a new ConvertTo-PodeYaml to generate Yaml documents