Skip to content

Commit 2ddf563

Browse files
committed
fix: follow path separator for windows
1 parent ca3da4b commit 2ddf563

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/internal/OpenApiTools/components/Reference.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,15 @@ export const generate = <T>(entryPoint: string, currentPoint: string, reference:
142142
targetPath = referencePoint.substring(fragmentIndex + 2);
143143
} else {
144144
const relativePathFromEntryPoint = path.relative(path.dirname(entryPoint), referencePoint); // components/hoge/fuga.yml
145-
if (!relativePathFromEntryPoint.startsWith("components")) {
145+
const pathArray: string[] = relativePathFromEntryPoint.split(path.sep); // ["components", "hoge", "fuga"]
146+
if (pathArray[0] != "components") {
146147
throw new DevelopmentError(`targetPath is not start "components":\n${relativePathFromEntryPoint}`);
147148
}
148149

149150
const ext = path.extname(relativePathFromEntryPoint); // .yml
150-
targetPath = relativePathFromEntryPoint.substring(0, relativePathFromEntryPoint.length - ext.length); // components/hoge/fuga
151+
targetPath = pathArray.join("/").substring(0, relativePathFromEntryPoint.length - ext.length); // components/hoge/fuga
151152
}
152-
const pathArray: string[] = targetPath.split(path.sep); // ["components", "hoge", "fuga"]
153+
const pathArray: string[] = targetPath.split("/"); // ["components", "hoge", "fuga"]
153154
const schemaName = pathArray[pathArray.length - 1]; // fuga
154155
const componentName = pathArray[0] === "components" ? pathArray[1] : "";
155156

0 commit comments

Comments
 (0)