Add support for OAS path params with dashes#2013
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for OpenAPI Specification (OAS) path parameters that contain dashes by modifying the parameter conversion logic to strip hyphens when converting to Express route format.
Key Changes:
- Updated regex pattern in parameter replacement to match parameters containing dashes (e.g.,
{param-id}) - Modified transformation logic to remove hyphens from parameter names since Express does not support them in route parameters
- Renamed
v2ParametersReplacetorouteParametersReplaceto better reflect its usage across both Swagger v2 and OpenAPI v3
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/commons/src/libs/openapi-converter.ts | Updated the parameter replacement method to handle dashes in OAS path parameters by expanding the regex pattern and stripping hyphens during conversion to Express format |
| packages/app/test/data/res/import-openapi/samples/custom-schema-v3.yaml | Added a test endpoint with path parameters containing dashes (/withparams/{paramName}/{param-id}) |
| packages/app/test/data/res/import-openapi/references/custom-schema-v3.json | Added expected test output showing the converted endpoint with dashes removed (withparams/:paramName/:paramid) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2012
Technical implementation details
Checklist
Closes #{issue_number}