Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OpenAPI Route Parameter Handling in Pode #1454

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

mdaneri
Copy link
Contributor

@mdaneri mdaneri commented Nov 13, 2024

Description:
This pull request addresses issue #1450, where routes containing parameters (e.g., /api/users/:userId) were not correctly added to the OpenAPI Routes list in Pode. This fix adjusts the code to properly recognize and add parameterized routes, ensuring they appear in the generated OpenAPI documentation.

Fix Details:
The modification was made in public/Route.ps1 at line 455.

Original Code:

if ($PodeContext.Server.OpenAPI.Routes -notcontains $OpenApiPath ) {
    $PodeContext.Server.OpenAPI.Routes += $OpenApiPath
}

Updated Code:

if ($PodeContext.Server.OpenAPI.Routes -notcontains $Path ) {
    $PodeContext.Server.OpenAPI.Routes += $Path
}

Issue and Solution Explanation:
The previous implementation checked and added the $OpenApiPath variable, which did not correctly account for routes with parameters, such as /api/users/:userId. By updating the condition to check and add $Path instead of $OpenApiPath, parameterized routes are now accurately identified and included in the Routes collection within Pode’s OpenAPI configuration.

Testing and Validation:

  • Verified that OpenAPI documentation includes parameterized routes as expected.
  • Confirmed that non-parameterized routes are unaffected by the change.

Copy link
Owner

@Badgerati Badgerati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Badgerati Badgerati linked an issue Nov 22, 2024 that may be closed by this pull request
@Badgerati Badgerati merged commit 508c2da into Badgerati:develop Nov 22, 2024
14 checks passed
@mdaneri mdaneri deleted the issue-1450 branch November 22, 2024 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenAPI route parameter definitions issue in v2.11.1
2 participants