Fix OpenAPI Route Path Conversion for Placeholder Unescaping and Relocate Function (#1422) #1423
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This pull request addresses issue #1422 regarding the handling of route placeholders for OpenAPI in Pode. The main issue was the improper unescaping of route placeholders, which affected OpenAPI route path generation.
Code Changes:
Function Rename:
The function
ConvertTo-PodeOpenApiRoutePath
has been renamed toConvertTo-PodeOARoutePath
for consistency with Pode's OpenAPI helper naming conventions.Placeholder Unescaping:
Placeholders (e.g.,
:potato
) are now correctly unescaped using[regex]::Unescape
to handle special characters properly in OpenAPI paths.Function Relocation:
The
ConvertTo-PodeOARoutePath
function has been moved from./Private/Route.ps1
to./Private/OpenApi.ps1
to better align with its intended purpose and OpenAPI-specific functionality.New Pester Test:
A new Pester 5.5 test has been added to validate the function's behavior. This test ensures that the function correctly converts routes like
'/v4.2/:potato'
and'/:potato'
into OpenAPI-compliant formats (e.g.,'/v4.2/{potato}'
and'/{potato}'
).Previous Implementation:
Updated Implementation:
Testing:
'/v4.2/:potato'
and'/:potato'
are correctly converted to'/v4.2/{potato}'
and'/{potato}'
, including proper handling of special characters.