Skip to content

Commit 8e44ea8

Browse files
committed
chore: normalize external path
1 parent 052341e commit 8e44ea8

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

dev/openapi-ts.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,20 @@ export default defineConfig(() => {
3535
// },
3636
path: path.resolve(
3737
getSpecsPath(),
38-
// '3.0.x',
39-
'3.1.x',
38+
'3.0.x',
39+
// '3.1.x',
4040
// 'circular.yaml',
4141
// 'dutchie.json',
4242
// 'enum-names-values.yaml',
4343
// 'invalid',
4444
// 'full.yaml',
45+
'sdk-method-class-conflict.yaml',
4546
// 'object-property-names.yaml',
4647
// 'openai.yaml',
4748
// 'opencode.yaml',
4849
// 'pagination-ref.yaml',
4950
// 'sdk-instance.yaml',
50-
'sdk-nested-classes.yaml',
51+
// 'sdk-nested-classes.yaml',
5152
// 'string-with-format.yaml',
5253
// 'transformers.json',
5354
// 'transformers-recursive.json',

packages/codegen-core/src/files/file.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import path from 'node:path';
2+
13
import type { ExportModule, ImportModule } from '../bindings';
24
import { fileBrand } from '../brands';
35
import { debug } from '../debug';
@@ -63,7 +65,7 @@ export class File {
6365
this.external = input.external ?? false;
6466
this.id = id;
6567
if (input.language !== undefined) this._language = input.language;
66-
this._logicalFilePath = input.logicalFilePath;
68+
this._logicalFilePath = input.logicalFilePath.split(path.sep).join('/');
6769
if (input.name !== undefined) this._name = input.name;
6870
this.project = project;
6971
}

packages/codegen-core/src/files/registry.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import path from 'node:path';
2+
13
import type { IProject } from '../project/types';
24
import { File } from './file';
35
import type { FileKeyArgs, IFileIn, IFileRegistry } from './types';
@@ -50,6 +52,7 @@ export class FileRegistry implements IFileRegistry {
5052
}
5153

5254
private createFileKey(args: FileKeyArgs): string {
53-
return `${args.external ? 'ext:' : ''}${args.logicalFilePath}${args.language ? `:${args.language}` : ''}`;
55+
const logicalPath = args.logicalFilePath.split(path.sep).join('/');
56+
return `${args.external ? 'ext:' : ''}${logicalPath}${args.language ? `:${args.language}` : ''}`;
5457
}
5558
}

packages/openapi-ts/src/ts-dsl/render/utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ export const moduleSortKey = ({
9797
preferFileExtension: string;
9898
root: string;
9999
}): SortKey => {
100-
const fromPath = fromFile.finalPath!;
101-
const filePath = file.finalPath!;
102-
let modulePath = fromPath;
100+
const filePath = file.finalPath!.split(path.sep).join('/');
101+
let modulePath = fromFile.finalPath!.split(path.sep).join('/');
103102

104103
// built-ins
105104
// TODO: based on nodeBuiltins set
@@ -110,7 +109,7 @@ export const moduleSortKey = ({
110109
}
111110

112111
// outside project root
113-
if (!modulePath.startsWith(root)) {
112+
if (!modulePath.startsWith(root.split(path.sep).join('/'))) {
114113
return [1, 0, modulePath];
115114
}
116115

0 commit comments

Comments
 (0)