express-openapi
express-openapi copied to clipboard
split(...).join is not a function error with Express v5
I get the following error when running Express v5:
TypeError: split(...).join is not a function
at ...\node_modules\@wesleytodd\openapi\lib\generate-doc.js:73:47
at Array.forEach (<anonymous>)
at iterateStack (...\node_modules\@wesleytodd\openapi\lib\generate-doc.js:71:24)
at ...\node_modules\@wesleytodd\openapi\lib\generate-doc.js:17:5
at Array.forEach (<anonymous>)
at generateDocument (...\node_modules\@wesleytodd\openapi\lib\generate-doc.js:16:26)
at OpenApiMiddleware (...\node_modules\@wesleytodd\openapi\index.js:41:29)
at Layer.handleRequest (...\node_modules\express\node_modules\router\lib\layer.js:101:15)
at trimPrefix (...\node_modules\express\node_modules\router\index.js:330:13)
at ...\node_modules\express\node_modules\router\index.js:291:7
The split function seems to reach the last "complex" return case, giving a string instead of an array
Is this with the newest version? I know there were some changes just recently in some of this code and just want to make sure we debug the right combo of things. I also assume you are on the latest express 5 prerelease?
No, sorry! I was trying to update versions and tried different combos.
This is the stack trace for
- "@wesleytodd/openapi": "^0.3.0"
- "express": "^5.0.0-beta.1"
TypeError: split(...).join is not a function
at ...\node_modules\@wesleytodd\openapi\lib\generate-doc.js:76:47
at Array.forEach (<anonymous>)
at iterateStack (...\node_modules\@wesleytodd\openapi\lib\generate-doc.js:74:24)
at ...\node_modules\@wesleytodd\openapi\lib\generate-doc.js:17:5
at Array.forEach (<anonymous>)
at generateDocument (...\node_modules\@wesleytodd\openapi\lib\generate-doc.js:16:26)
at OpenApiMiddleware (...\node_modules\@wesleytodd\openapi\index.js:42:29)
at Layer.handleRequest (...\node_modules\express\node_modules\router\lib\layer.js:101:15)
at trimPrefix (...\node_modules\express\node_modules\router\index.js:330:13)
at ...\node_modules\express\node_modules\router\index.js:291:7
The input to split is /^(?:\/(?=$))?/i
and it ends up in the last return case which is a string
.
Ah ok, yeah maybe we should put together a test to cover express@5
. I should have thought of this before, it is a breaking change for a reason lol. Also would be happy to see a PR fixing this on the latest if you want, OSS is a team sport!
I think this is fixed. Please re open if you are on latest and it is still an issue. We added tests and everything to do multiple express major testing.