Closed XanderEndre closed 1 year ago
Opened PR #869 to resolve this issue.
Opened another PR #877 that modifies fs-routes
instead and fixes this issue and also #871
Still a problem over here - any workarounds yet?
I'm also still seeing this issue:
\node_modules\path-to-regexp\index.js:128
return new RegExp(path, flags);
^
SyntaxError: Invalid regular expression: /^\/api\v1\users\(?:([^\/]+?))\/?$/: Unmatched ')'
at new RegExp (<anonymous>)
at pathtoRegexp (D:\Projects\REDACTED\REDACTED-api\node_modules\path-to-regexp\index.js:128:10)
at new Layer (D:\Projects\REDACTED\REDACTED-api\node_modules\express\lib\router\layer.js:45:17)
at Function.route (D:\Projects\REDACTED\REDACTED-api\node_modules\express\lib\router\index.js:505:15)
at Function.app.<computed> [as get] (D:\Projects\REDACTED\REDACTED-api\node_modules\express\lib\application.js:498:30)
at Object.visitOperation (D:\Projects\REDACTED\REDACTED-api\node_modules\express-openapi\index.ts:205:25)
at D:\Projects\REDACTED\REDACTED-api\node_modules\openapi-framework\index.ts:605:19
at Set.forEach (<anonymous>)
at D:\Projects\REDACTED\REDACTED-api\node_modules\openapi-framework\index.ts:364:9
at Array.forEach (<anonymous>)
I also have a similar structure where I'm using {id}.js
. This issue only happens on Windows, my Mac/Linux workstations don't have these issues.
Package.json
"express-openapi": "^12.1.3"
Hi there,
I've encountered an issue when using express-openapi with my Express.js application. This application was based on a fresh installation.
The error I'm facing is as follows:
This error occurs when my application is starting up.
Here is my project structure:
Here is my package.json
Here is my code for the
test.js
,customer.js
, andcustomer/{id}.js
I am following the guidelines mentioned in the express-openapi documentation to structure my path files and use the {id} syntax for URL parameters.
Interestingly, I can access the /test route without any issues. However, I am not able to access the /customer by itself. I receive a 404 error. When adding the /customer/{id} file I receive the error detailed above.
The error seems to be related to the path-to-regexp module, but I'm not directly using this module in my code. It's being used internally by express-openapi.
I suspect the issue is due to the {id} file name, which could be getting passed as a part of the path to the path-to-regexp function.
If you could help me understand what's causing this error and how I could resolve it, I would greatly appreciate it. Please let me know if you need any further information. If you know better ways to debug this code or get a better error message, please let me know.
Thank you for your time and assistance!