Skip to content

Commit 4365b63

Browse files
committed
fix: problem with query params in route name (#439)
1 parent d4a9120 commit 4365b63

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/schema-parser/schema-routes.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,37 +129,36 @@ class SchemaRoutes {
129129
);
130130

131131
const queryParamMatches = fixedRoute.match(/(\{\?.*\})/g);
132+
const queryParams = [];
132133

133134
if (queryParamMatches && queryParamMatches.length) {
134135
queryParamMatches.forEach((match) => {
135136
fixedRoute = fixedRoute.replace(match, "");
136137
});
137-
}
138138

139-
const queryParams = _.uniq(
140-
queryParamMatches
141-
.join(",")
142-
.replace(/(\{\?)|(\})|\s/g, "")
143-
.split(","),
144-
).reduce((acc, paramName) => {
145-
if (_.includes(paramName, "-")) {
146-
this.logger.warn("wrong query param name", paramName);
147-
}
139+
_.uniq(
140+
queryParamMatches
141+
.join(",")
142+
.replace(/(\{\?)|(\})|\s/g, "")
143+
.split(","),
144+
).forEach((paramName) => {
145+
if (_.includes(paramName, "-")) {
146+
this.logger.warn("wrong query param name", paramName);
147+
}
148148

149-
acc.push({
150-
$match: paramName,
151-
name: _.camelCase(paramName),
152-
required: true,
153-
type: "string",
154-
description: "",
155-
schema: {
149+
queryParams.push({
150+
$match: paramName,
151+
name: _.camelCase(paramName),
152+
required: true,
156153
type: "string",
157-
},
158-
in: "query",
154+
description: "",
155+
schema: {
156+
type: "string",
157+
},
158+
in: "query",
159+
});
159160
});
160-
161-
return acc;
162-
}, []);
161+
}
163162

164163
return {
165164
originalRoute: routeName || "",

0 commit comments

Comments
 (0)