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 to ConvertTo-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}').
Added a new Pester 5.5 test to validate the function's behavior. The test confirms that paths such as '/v4.2/:potato' and '/:potato' are correctly converted to '/v4.2/{potato}' and '/{potato}', including proper handling of special characters.
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.