Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/schema-routes/schema-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ export class SchemaRoutes {
]);
}

createRequestsMap = (routeInfoByMethodsMap) => {
const parameters = lodash.get(routeInfoByMethodsMap, "parameters");
createRequestsMap = (routesByMethod) => {
const parameters = lodash.get(routesByMethod, "parameters");

return lodash.reduce(
routeInfoByMethodsMap,
routesByMethod,
(acc, requestInfo, method) => {
if (
method.startsWith("x-") ||
Expand All @@ -91,10 +91,9 @@ export class SchemaRoutes {
);
};

parseRouteName = (originalRouteName) => {
parseRouteName = (rawRoute) => {
const routeName =
this.config.hooks.onPreBuildRoutePath(originalRouteName) ||
originalRouteName;
this.config.hooks.onPreBuildRoutePath(rawRoute) || rawRoute;

// TODO forbid leading symbols [\]^` in a major release (allowed yet for backwards compatibility)
const pathParamMatches = (routeName || "").match(
Expand Down Expand Up @@ -157,15 +156,16 @@ export class SchemaRoutes {
);

for (const paramName of paramNames) {
// @ts-expect-error TS(2339) FIXME: Property 'includes' does not exist on type 'unknow... Remove this comment to see the full error message
if (paramName.includes("-")) {
if (typeof paramName === "string" && paramName.includes("-")) {
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type guard typeof paramName === 'string' appears unnecessary here. The paramNames array is populated from string operations (splitting comma-separated values from regex matches), so all elements should already be strings. This check adds defensive programming but may indicate uncertainty about the data type. Consider simplifying or documenting why non-string values are expected.

Copilot uses AI. Check for mistakes.
consola.warn("wrong query param name", paramName);
}

queryParams.push({
$match: paramName,
// @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message
name: lodash.camelCase(paramName),
name:
typeof paramName === "string"
? lodash.camelCase(paramName)
: lodash.camelCase(String(paramName)),
Comment on lines +165 to +168
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional handling of paramName is redundant. Since paramNames is derived from string operations (splitting and replacing), all elements should already be strings. The typeof paramName === 'string' check and the fallback String(paramName) add unnecessary complexity. Consider simplifying to just lodash.camelCase(paramName) or adding an assertion if type safety is the concern.

Suggested change
name:
typeof paramName === "string"
? lodash.camelCase(paramName)
: lodash.camelCase(String(paramName)),
name: lodash.camelCase(paramName),

Copilot uses AI. Check for mistakes.
required: true,
type: "string",
description: "",
Expand All @@ -178,7 +178,7 @@ export class SchemaRoutes {
}

const result = {
originalRoute: originalRouteName || "",
originalRoute: rawRoute || "",
route: fixedRoute,
pathParams,
queryParams,
Expand Down Expand Up @@ -416,8 +416,7 @@ export class SchemaRoutes {
lodash.reduce(
requestInfos,
(acc, requestInfo, status) => {
// @ts-expect-error TS(2554) FIXME: Expected 2 arguments, but got 1.
const contentTypes = this.getContentTypes([requestInfo]);
const contentTypes = this.getContentTypes([requestInfo], operationId);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Incorrect Argument Type Causes Spread Operator Error

The getContentTypes method receives operationId (a string) as its second argument, but it expects an array. This causes the spread operator to iterate over the string's characters, leading to incorrect content type processing.

Fix in Cursor Fix in Web


return [
...acc,
Expand Down
Loading