Closed mdaneri closed 1 month ago
When Enable-PodeOpenAPI is invoked using the -NoDefaultResponses parameter and an OpenAPI path is created without adding a response, the generated OpenAPI specification is not correct.
Enable-PodeOpenAPI
-NoDefaultResponses
Run the following PowerShell commands:
Enable-PodeOpenApi -Path '/docs/openapi' -OpenApiVersion '3.0.3' -DisableMinimalDefinitions -NoDefaultResponses Add-PodeRoute -Method 'Get' -Path '/hello' -ScriptBlock { Write-PodeJsonResponse -Value @{'message' = 'Hello!'} -StatusCode 200 } -PassThru | Set-PodeOARouteInfo -Summary 'Hello from the server'
This generates the following OpenAPI YAML:
/hello: get: summary: Hello from the server responses: []
This output is not compliant with the OpenAPI specification.
If no response is added, a default response should be automatically added. The corrected OpenAPI YAML should look like this:
/hello: get: summary: Hello from the server responses: default: description: No description
Automatically add a default response when no responses are specified to ensure compliance with the OpenAPI specification.
Describe the Bug
When
Enable-PodeOpenAPI
is invoked using the-NoDefaultResponses
parameter and an OpenAPI path is created without adding a response, the generated OpenAPI specification is not correct.Steps To Reproduce
Run the following PowerShell commands:
This generates the following OpenAPI YAML:
This output is not compliant with the OpenAPI specification.
Expected Behavior
If no response is added, a default response should be automatically added. The corrected OpenAPI YAML should look like this:
Fix
Automatically add a default response when no responses are specified to ensure compliance with the OpenAPI specification.