Closed antyale closed 2 years ago
Wow, such regex on path parameter is really possible? I hadn't known at all.
Can you give me any guideline document about the regex path? I'll implement this feature until next wekk's Saturday.
It's okay that do not wait my implementation but sending PR by yourself ^^
Yes, it is something that Express allows, you can more details here (https://expressjs.com/en/guide/routing.html). According to the documentation: To have more control over the exact string that can be matched by a route parameter, you can append a regular expression in parentheses (())
.
I actually made a quick fix locally in the ReflectAnalyzer.ts using map
:
const funcPathArguments: string[] = StringUtil.betweens(
NodePath.join(controllerPath, metaPath)
.split("\\")
.join("/"),
":",
"/",
).sort()
// Ignore regex when validating path arguments
.map(pathArgument => pathArgument.split('(')[0]);
That solved the validation issue but I found that the json spec is generated with the regex:
"/call/{id}([0-9a-f]{24})": {
"get": { .... }
I didn't have time to check that part yet, but I believe that this is not allowed in the openapi specification :sweat_smile:
@antyale
express
is parsing the regex path using path-to-regexp.
Therefore, I will also utilize the library to support full path spec of the express
.
Thanks for reporting.
@antyale New version nestia@3.0.11
supports the regex path.
Bug Report
Summary
Validating path arguments does not take into account possible regex in the route parameters.
For example, the following endpoint:
Will fail when generating the swagger json spec with
Error on CallController.getCall(): binded arguments in the "path" between function's decorator and parameters' decorators are different (function: [id([0-9a-f]{24})], parameters: [id])