ts-openapi-codegen 2.0.0-beta.6 → 2.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -74
- package/README.rus.md +0 -73
- package/dist/cli/initOpenApiConfig/Types.d.ts +0 -5
- package/dist/cli/initOpenApiConfig/Types.d.ts.map +1 -1
- package/dist/common/utils/fileSystemHelpers.d.ts +0 -2
- package/dist/common/utils/fileSystemHelpers.d.ts.map +1 -1
- package/dist/common/utils/fileSystemHelpers.js +0 -9
- package/dist/core/Context.d.ts +22 -0
- package/dist/core/Context.d.ts.map +1 -1
- package/dist/core/Context.js +97 -0
- package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModels.js +1 -2
- package/dist/core/api/v2/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getType.js +14 -8
- package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModels.js +1 -2
- package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getType.js +14 -8
- package/dist/core/utils/getOpenApiSpec.d.ts +0 -6
- package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
- package/dist/core/utils/getOpenApiSpec.js +13 -23
- package/dist/core/utils/stripNamespace.js +1 -1
- package/package.json +1 -7
- package/dist/cli/initOpenApiConfig/Enums.d.ts +0 -5
- package/dist/cli/initOpenApiConfig/Enums.d.ts.map +0 -1
- package/dist/cli/initOpenApiConfig/Enums.js +0 -8
- package/dist/core/types/base/RefWithtype.model.d.ts +0 -11
- package/dist/core/types/base/RefWithtype.model.d.ts.map +0 -1
- package/dist/core/types/base/RefWithtype.model.js +0 -2
- package/dist/core/types/enums/TypeRef.enum.d.ts +0 -8
- package/dist/core/types/enums/TypeRef.enum.d.ts.map +0 -1
- package/dist/core/types/enums/TypeRef.enum.js +0 -11
- package/dist/core/utils/__tests__/getGatheringRefs.test.d.ts +0 -2
- package/dist/core/utils/__tests__/getGatheringRefs.test.d.ts.map +0 -1
- package/dist/core/utils/__tests__/getGatheringRefs.test.js +0 -26
- package/dist/core/utils/__tests__/getRefFromSchema.test.d.ts +0 -2
- package/dist/core/utils/__tests__/getRefFromSchema.test.d.ts.map +0 -1
- package/dist/core/utils/__tests__/getRefFromSchema.test.js +0 -167
- package/dist/core/utils/__tests__/refResolver.test.d.ts +0 -2
- package/dist/core/utils/__tests__/refResolver.test.d.ts.map +0 -1
- package/dist/core/utils/__tests__/refResolver.test.js +0 -55
- package/dist/core/utils/__tests__/resolveRefToImportPath.test.d.ts +0 -2
- package/dist/core/utils/__tests__/resolveRefToImportPath.test.d.ts.map +0 -1
- package/dist/core/utils/__tests__/resolveRefToImportPath.test.js +0 -449
- package/dist/core/utils/findCommonParent.d.ts +0 -7
- package/dist/core/utils/findCommonParent.d.ts.map +0 -1
- package/dist/core/utils/findCommonParent.js +0 -20
- package/dist/core/utils/getGatheringRefs.d.ts +0 -4
- package/dist/core/utils/getGatheringRefs.d.ts.map +0 -1
- package/dist/core/utils/getGatheringRefs.js +0 -68
- package/dist/core/utils/getRefFromSchema.d.ts +0 -3
- package/dist/core/utils/getRefFromSchema.d.ts.map +0 -1
- package/dist/core/utils/getRefFromSchema.js +0 -9
- package/dist/core/utils/isBoolean.d.ts +0 -2
- package/dist/core/utils/isBoolean.d.ts.map +0 -1
- package/dist/core/utils/isBoolean.js +0 -12
- package/dist/core/utils/isFileName.d.ts +0 -7
- package/dist/core/utils/isFileName.d.ts.map +0 -1
- package/dist/core/utils/isFileName.js +0 -30
- package/dist/core/utils/mapPathToTargetDirSafe.d.ts +0 -10
- package/dist/core/utils/mapPathToTargetDirSafe.d.ts.map +0 -1
- package/dist/core/utils/mapPathToTargetDirSafe.js +0 -48
- package/dist/core/utils/normalizeAllRefs.d.ts +0 -6
- package/dist/core/utils/normalizeAllRefs.d.ts.map +0 -1
- package/dist/core/utils/normalizeAllRefs.js +0 -35
- package/dist/core/utils/resolveRefToImportPath.d.ts +0 -13
- package/dist/core/utils/resolveRefToImportPath.d.ts.map +0 -1
- package/dist/core/utils/resolveRefToImportPath.js +0 -106
package/README.md
CHANGED
|
@@ -526,80 +526,6 @@ export function request<T>(config: TOpenAPIConfig, options: ApiRequestOptions):
|
|
|
526
526
|
}
|
|
527
527
|
```
|
|
528
528
|
|
|
529
|
-
### Custom Request Executor
|
|
530
|
-
|
|
531
|
-
Starting from version 2.0.0-beta.1, generated services use the `RequestExecutor` interface instead of calling the core `request` function directly. This allows you to provide your own request implementation or adapt existing ones.
|
|
532
|
-
|
|
533
|
-
**Using a custom RequestExecutor:**
|
|
534
|
-
|
|
535
|
-
You can create your own `RequestExecutor` implementation:
|
|
536
|
-
|
|
537
|
-
```ts
|
|
538
|
-
import type { RequestExecutor, RequestConfig } from './generated/core/request-executor';
|
|
539
|
-
import { SimpleService } from './generated/services/SimpleService';
|
|
540
|
-
|
|
541
|
-
// Define your custom options type (optional)
|
|
542
|
-
interface MyCustomOptions {
|
|
543
|
-
timeout?: number;
|
|
544
|
-
retries?: number;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
// Create a custom executor
|
|
548
|
-
const customExecutor: RequestExecutor<MyCustomOptions> = {
|
|
549
|
-
async request<TResponse>(config: RequestConfig, options?: MyCustomOptions): Promise<TResponse> {
|
|
550
|
-
// Your custom request logic here
|
|
551
|
-
const response = await fetch(config.url, {
|
|
552
|
-
method: config.method,
|
|
553
|
-
headers: config.headers,
|
|
554
|
-
body: config.body ? JSON.stringify(config.body) : undefined,
|
|
555
|
-
signal: options?.timeout ? AbortSignal.timeout(options.timeout) : undefined,
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
if (!response.ok) {
|
|
559
|
-
throw new Error(`Request failed: ${response.statusText}`);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
return response.json();
|
|
563
|
-
},
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
// Use it with generated services
|
|
567
|
-
const simpleService = new SimpleService<MyCustomOptions>(customExecutor);
|
|
568
|
-
await simpleService.getCallWithoutParametersAndResponse({ timeout: 5000, retries: 3 });
|
|
569
|
-
```
|
|
570
|
-
|
|
571
|
-
**Using legacy request adapter:**
|
|
572
|
-
|
|
573
|
-
If you have an existing custom `request` file (specified via `--request` option), you can use the `createLegacyExecutor` helper to adapt it to the new `RequestExecutor` interface:
|
|
574
|
-
|
|
575
|
-
```ts
|
|
576
|
-
import { createLegacyExecutor } from './generated/core/legacy-request-adapter';
|
|
577
|
-
import { OpenAPI } from './generated/core/OpenAPI';
|
|
578
|
-
import { SimpleService } from './generated/services/SimpleService';
|
|
579
|
-
|
|
580
|
-
// The legacy adapter wraps your existing request function
|
|
581
|
-
const executor = createLegacyExecutor(OpenAPI);
|
|
582
|
-
|
|
583
|
-
// Optionally, you can map custom options to ApiRequestOptions
|
|
584
|
-
interface XHROptions {
|
|
585
|
-
timeout?: number;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
const executorWithOptions = createLegacyExecutor<XHROptions>(OpenAPI, (options) => {
|
|
589
|
-
// Map your custom options to ApiRequestOptions if needed
|
|
590
|
-
return {
|
|
591
|
-
// Add any ApiRequestOptions fields based on options
|
|
592
|
-
};
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
// Use with services
|
|
596
|
-
const simpleService = new SimpleService(executor);
|
|
597
|
-
await simpleService.getCallWithoutParametersAndResponse();
|
|
598
|
-
```
|
|
599
|
-
|
|
600
|
-
**Note:** The `--request` option still works for customizing the core `request` function. The generated
|
|
601
|
-
`legacy-request-adapter` will automatically use your custom request implementation when creating the adapter.
|
|
602
|
-
|
|
603
529
|
### Sorting strategy for function arguments `--sortByRequired`
|
|
604
530
|
By default, the OpenAPI generator sorts the parameters of service functions according to a simplified scheme. If you need a more strict sorting option, then you need to use the `--sortByRequired` flag. The simplified sorting option is similar to the one used in version 0.2.3 of the OpenAPI generator. This flag allows you to upgrade to a new version of the generator if you are "stuck" on version 0.2.3.
|
|
605
531
|
|
package/README.rus.md
CHANGED
|
@@ -526,79 +526,6 @@ export function request<T>(config: TOpenAPIConfig, options: ApiRequestOptions):
|
|
|
526
526
|
}
|
|
527
527
|
```
|
|
528
528
|
|
|
529
|
-
### Пользовательский Request Executor
|
|
530
|
-
|
|
531
|
-
Начиная с версии 2.0.0, сгенерированные сервисы используют интерфейс `RequestExecutor` вместо прямых вызовов core-функции `request`. Это позволяет вам предоставить свою собственную реализацию запросов или адаптировать существующие.
|
|
532
|
-
|
|
533
|
-
**Использование пользовательского RequestExecutor:**
|
|
534
|
-
|
|
535
|
-
Вы можете создать свою собственную реализацию `RequestExecutor`:
|
|
536
|
-
|
|
537
|
-
```ts
|
|
538
|
-
import type { RequestExecutor, RequestConfig } from './generated/core/request-executor';
|
|
539
|
-
import { SimpleService } from './generated/services/SimpleService';
|
|
540
|
-
|
|
541
|
-
// Определите свой тип опций (опционально)
|
|
542
|
-
interface MyCustomOptions {
|
|
543
|
-
timeout?: number;
|
|
544
|
-
retries?: number;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
// Создайте пользовательский executor
|
|
548
|
-
const customExecutor: RequestExecutor<MyCustomOptions> = {
|
|
549
|
-
async request<TResponse>(config: RequestConfig, options?: MyCustomOptions): Promise<TResponse> {
|
|
550
|
-
// Ваша пользовательская логика запросов здесь
|
|
551
|
-
const response = await fetch(config.url, {
|
|
552
|
-
method: config.method,
|
|
553
|
-
headers: config.headers,
|
|
554
|
-
body: config.body ? JSON.stringify(config.body) : undefined,
|
|
555
|
-
signal: options?.timeout ? AbortSignal.timeout(options.timeout) : undefined,
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
if (!response.ok) {
|
|
559
|
-
throw new Error(`Request failed: ${response.statusText}`);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
return response.json();
|
|
563
|
-
},
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
// Используйте его со сгенерированными сервисами
|
|
567
|
-
const simpleService = new SimpleService<MyCustomOptions>(customExecutor);
|
|
568
|
-
await simpleService.getCallWithoutParametersAndResponse({ timeout: 5000, retries: 3 });
|
|
569
|
-
```
|
|
570
|
-
|
|
571
|
-
**Использование legacy request adapter:**
|
|
572
|
-
|
|
573
|
-
Если у вас есть существующий пользовательский файл `request` (указанный через опцию `--request`), вы можете использовать хелпер `createLegacyExecutor` для адаптации его к новому интерфейсу `RequestExecutor`:
|
|
574
|
-
|
|
575
|
-
```ts
|
|
576
|
-
import { createLegacyExecutor } from './generated/core/legacy-request-adapter';
|
|
577
|
-
import { OpenAPI } from './generated/core/OpenAPI';
|
|
578
|
-
import { SimpleService } from './generated/services/SimpleService';
|
|
579
|
-
|
|
580
|
-
// Legacy адаптер оборачивает вашу существующую функцию request
|
|
581
|
-
const executor = createLegacyExecutor(OpenAPI);
|
|
582
|
-
|
|
583
|
-
// Опционально, вы можете мапить пользовательские опции в ApiRequestOptions
|
|
584
|
-
interface XHROptions {
|
|
585
|
-
timeout?: number;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
const executorWithOptions = createLegacyExecutor<XHROptions>(OpenAPI, (options) => {
|
|
589
|
-
// Мапьте ваши пользовательские опции в ApiRequestOptions при необходимости
|
|
590
|
-
return {
|
|
591
|
-
// Добавьте любые поля ApiRequestOptions на основе options
|
|
592
|
-
};
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
// Используйте со сервисами
|
|
596
|
-
const simpleService = new SimpleService(executor);
|
|
597
|
-
await simpleService.getCallWithoutParametersAndResponse();
|
|
598
|
-
```
|
|
599
|
-
|
|
600
|
-
**Примечание:** Опция --request по-прежнему работает для кастомизации core-функции request. Сгенерированный legacy-request-adapter автоматически будет использовать вашу пользовательскую реализацию request при создании адаптера.
|
|
601
|
-
|
|
602
529
|
### Стратегия сортировки аргументов функций `--sortByRequired`
|
|
603
530
|
По умолчанию генератор OpenAPI сортирует параметры сервисных функций согласно упрощенной схеме. Если вам нужна более строгая опция сортировки, используйте флаг `--sortByRequired`. Упрощенная опция сортировки похожа на ту, что использовалась в версии 0.2.3 генератора OpenAPI. Этот флаг позволяет обновиться до новой версии генератора, если вы "застряли" на версии 0.2.3.
|
|
604
531
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../src/cli/initOpenApiConfig/Types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../src/cli/initOpenApiConfig/Types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACvB,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;IACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;IACrC,eAAe,EAAE,UAAU,CAAC,gBAAgB,CAAC;CAChD,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { copyFile as __copyFile, exists as __exists, readdir as __readdir, readFile as __readFile, writeFile as __writeFile } from 'fs';
|
|
2
2
|
declare function isDirectory(path: string): boolean;
|
|
3
3
|
declare function isPathToFile(path: string): boolean;
|
|
4
|
-
declare function isSameFilePath(a: string, b: string): boolean;
|
|
5
4
|
declare const fileSystemHelpers: {
|
|
6
5
|
readFile: typeof __readFile.__promisify__;
|
|
7
6
|
writeFile: typeof __writeFile.__promisify__;
|
|
@@ -13,7 +12,6 @@ declare const fileSystemHelpers: {
|
|
|
13
12
|
isDirectory: typeof isDirectory;
|
|
14
13
|
isPathToFile: typeof isPathToFile;
|
|
15
14
|
readdir: typeof __readdir.__promisify__;
|
|
16
|
-
isSameFilePath: typeof isSameFilePath;
|
|
17
15
|
};
|
|
18
16
|
export { fileSystemHelpers };
|
|
19
17
|
//# sourceMappingURL=fileSystemHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileSystemHelpers.d.ts","sourceRoot":"","sources":["../../../src/common/utils/fileSystemHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,IAAI,UAAU,EAEtB,MAAM,IAAI,QAAQ,EAElB,OAAO,IAAI,SAAS,EACpB,QAAQ,IAAI,UAAU,
|
|
1
|
+
{"version":3,"file":"fileSystemHelpers.d.ts","sourceRoot":"","sources":["../../../src/common/utils/fileSystemHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,IAAI,UAAU,EAEtB,MAAM,IAAI,QAAQ,EAElB,OAAO,IAAI,SAAS,EACpB,QAAQ,IAAI,UAAU,EAKtB,SAAS,IAAI,WAAW,EAC3B,MAAM,IAAI,CAAC;AA0DZ,iBAAS,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM1C;AAED,iBAAS,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM3C;AAED,QAAA,MAAM,iBAAiB;;;;;;kBArDI,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;kBAgBtB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;;;;CAgDhD,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -73,14 +73,6 @@ function isPathToFile(path) {
|
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
function isSameFilePath(a, b) {
|
|
77
|
-
try {
|
|
78
|
-
return (0, fs_1.realpathSync)(a) === (0, fs_1.realpathSync)(b);
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
76
|
const fileSystemHelpers = {
|
|
85
77
|
readFile,
|
|
86
78
|
writeFile,
|
|
@@ -92,6 +84,5 @@ const fileSystemHelpers = {
|
|
|
92
84
|
isDirectory,
|
|
93
85
|
isPathToFile,
|
|
94
86
|
readdir,
|
|
95
|
-
isSameFilePath,
|
|
96
87
|
};
|
|
97
88
|
exports.fileSystemHelpers = fileSystemHelpers;
|
package/dist/core/Context.d.ts
CHANGED
|
@@ -14,6 +14,15 @@ type RefsLike = {
|
|
|
14
14
|
paths: (...args: any[]) => string[];
|
|
15
15
|
exists: (...args: any[]) => boolean;
|
|
16
16
|
};
|
|
17
|
+
interface VirtualFile {
|
|
18
|
+
/** Абсолютный путь исходного файла (БЕЗ fragment) */
|
|
19
|
+
sourceFile: string;
|
|
20
|
+
/** Абсолютный путь output-файла (.ts) */
|
|
21
|
+
outputFile: string;
|
|
22
|
+
/** Все fragment'ы, которые встречались у этого файла */
|
|
23
|
+
fragments: Set<string>;
|
|
24
|
+
}
|
|
25
|
+
type VirtualFileMap = Map<string, VirtualFile>;
|
|
17
26
|
/**
|
|
18
27
|
* A Context wich can share a data between methods
|
|
19
28
|
*/
|
|
@@ -23,6 +32,8 @@ export declare class Context {
|
|
|
23
32
|
private _output;
|
|
24
33
|
prefix: PrefixArtifacts;
|
|
25
34
|
private _sortByRequired;
|
|
35
|
+
private specRoot;
|
|
36
|
+
private virtualFiles;
|
|
26
37
|
constructor({ input, output, prefix, sortByRequired }: TContextProps);
|
|
27
38
|
addRefs(refs: RefsLike): Context;
|
|
28
39
|
values(...types: string[]): Record<string, any>;
|
|
@@ -33,6 +44,17 @@ export declare class Context {
|
|
|
33
44
|
get output(): OutputPaths;
|
|
34
45
|
get sortByRequired(): boolean;
|
|
35
46
|
get root(): $Root | undefined;
|
|
47
|
+
private canonicalizeRef;
|
|
48
|
+
private mapSourceToOutput;
|
|
49
|
+
private registerRef;
|
|
50
|
+
private walkSchema;
|
|
51
|
+
initializeVirtualFileMap(rootSchema: unknown, entryFile: string): void;
|
|
52
|
+
getVirtualFiles(): VirtualFileMap;
|
|
53
|
+
getAllCanonicalRefs(): string[];
|
|
54
|
+
resolveCanonicalRef(canonicalRef: string): {
|
|
55
|
+
outputFile: string;
|
|
56
|
+
fragment?: string;
|
|
57
|
+
} | undefined;
|
|
36
58
|
}
|
|
37
59
|
export {};
|
|
38
60
|
//# sourceMappingURL=Context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/core/Context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/core/Context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAIhF,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAKhD,KAAK,aAAa,GAAG;IACjB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,KAAK,QAAQ,GAAG;IACZ,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChD,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,eAAe,GAAG,eAAe,GAAG,eAAe,CAAC;IAC7E,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,EAAE,CAAC;IACpC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;CACvC,CAAC;AAEF,UAAU,WAAW;IACjB,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC;IAEnB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IAEnB,wDAAwD;IACxD,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC1B;AAED,KAAK,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAE/C;;GAEG;AACH,qBAAa,OAAO;IAChB,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,OAAO,CAAc;IACtB,MAAM,EAAE,eAAe,CAI5B;IAEF,OAAO,CAAC,eAAe,CAAkB;IAEzC,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,YAAY,CAA6B;gBAErC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,aAAa;IAmB7D,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO;IAKhC,MAAM,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAO/C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,eAAe,GAAG,eAAe;IAOtE,KAAK,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAOnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAO7B,QAAQ,IAAI,MAAM;IAOzB,IAAW,MAAM,gBAKhB;IAED,IAAW,cAAc,YAExB;IAED,IAAW,IAAI,IAAI,KAAK,GAAG,SAAS,CAEnC;IAED,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,UAAU;IAiBX,wBAAwB,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM;IAiB/D,eAAe,IAAI,cAAc;IAIjC,mBAAmB,IAAI,MAAM,EAAE;IAgB/B,mBAAmB,CAAC,YAAY,EAAE,MAAM,GACzC;QACI,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACrB,GACD,SAAS;CAYlB"}
|
package/dist/core/Context.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Context = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
4
5
|
const pathHelpers_1 = require("../common/utils/pathHelpers");
|
|
5
6
|
const getFileName_1 = require("./utils/getFileName");
|
|
6
7
|
const isString_1 = require("./utils/isString");
|
|
8
|
+
const parseRef_1 = require("./utils/parseRef");
|
|
7
9
|
/**
|
|
8
10
|
* A Context wich can share a data between methods
|
|
9
11
|
*/
|
|
@@ -17,6 +19,8 @@ class Context {
|
|
|
17
19
|
type: 'T',
|
|
18
20
|
};
|
|
19
21
|
_sortByRequired = false;
|
|
22
|
+
specRoot;
|
|
23
|
+
virtualFiles = new Map();
|
|
20
24
|
constructor({ input, output, prefix, sortByRequired }) {
|
|
21
25
|
this._output = output;
|
|
22
26
|
this._refs = {};
|
|
@@ -80,5 +84,98 @@ class Context {
|
|
|
80
84
|
get root() {
|
|
81
85
|
return this._root;
|
|
82
86
|
}
|
|
87
|
+
canonicalizeRef(ref, parentSourceFile) {
|
|
88
|
+
const parsed = (0, parseRef_1.parseRef)(ref);
|
|
89
|
+
// LOCAL_FRAGMENT → тот же файл
|
|
90
|
+
if (parsed.type === parseRef_1.RefType.LOCAL_FRAGMENT) {
|
|
91
|
+
return {
|
|
92
|
+
sourceFile: (0, pathHelpers_1.normalizeHelper)(parentSourceFile),
|
|
93
|
+
fragment: parsed.fragment,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// Внешний ref
|
|
97
|
+
const parentDir = (0, pathHelpers_1.dirNameHelper)(parentSourceFile);
|
|
98
|
+
const absSource = (0, pathHelpers_1.resolveHelper)(parentDir, parsed.filePath);
|
|
99
|
+
return {
|
|
100
|
+
sourceFile: (0, pathHelpers_1.normalizeHelper)(absSource),
|
|
101
|
+
fragment: parsed.fragment,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
mapSourceToOutput(sourceFile) {
|
|
105
|
+
const relative = (0, pathHelpers_1.relativeHelper)(this.specRoot, sourceFile);
|
|
106
|
+
const dir = (0, pathHelpers_1.dirNameHelper)(relative);
|
|
107
|
+
const baseName = (0, path_1.basename)(relative).replace(/\.(yaml|yml|json)$/i, '.ts');
|
|
108
|
+
return (0, pathHelpers_1.resolveHelper)(this.output.outputModels, dir, baseName);
|
|
109
|
+
}
|
|
110
|
+
registerRef(ref, parentSourceFile) {
|
|
111
|
+
const { sourceFile, fragment } = this.canonicalizeRef(ref, parentSourceFile);
|
|
112
|
+
let entry = this.virtualFiles.get(sourceFile);
|
|
113
|
+
if (!entry) {
|
|
114
|
+
entry = {
|
|
115
|
+
sourceFile,
|
|
116
|
+
outputFile: this.mapSourceToOutput(sourceFile),
|
|
117
|
+
fragments: new Set(),
|
|
118
|
+
};
|
|
119
|
+
this.virtualFiles.set(sourceFile, entry);
|
|
120
|
+
}
|
|
121
|
+
if (fragment) {
|
|
122
|
+
entry.fragments.add(fragment);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
walkSchema(obj, parentSourceFile) {
|
|
126
|
+
if (!obj || typeof obj !== 'object')
|
|
127
|
+
return;
|
|
128
|
+
if (typeof obj.$ref === 'string') {
|
|
129
|
+
this.registerRef(obj.$ref, parentSourceFile);
|
|
130
|
+
}
|
|
131
|
+
if (Array.isArray(obj)) {
|
|
132
|
+
obj.forEach(item => this.walkSchema(item, parentSourceFile));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
for (const value of Object.values(obj)) {
|
|
136
|
+
this.walkSchema(value, parentSourceFile);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
initializeVirtualFileMap(rootSchema, entryFile) {
|
|
140
|
+
this.specRoot = (0, pathHelpers_1.normalizeHelper)((0, pathHelpers_1.dirNameHelper)(entryFile));
|
|
141
|
+
const normalizedEntry = (0, pathHelpers_1.normalizeHelper)(entryFile);
|
|
142
|
+
// Гарантируем, что entry файл тоже есть в карте
|
|
143
|
+
if (!this.virtualFiles.has(normalizedEntry)) {
|
|
144
|
+
this.virtualFiles.set(normalizedEntry, {
|
|
145
|
+
sourceFile: normalizedEntry,
|
|
146
|
+
outputFile: this.mapSourceToOutput(normalizedEntry),
|
|
147
|
+
fragments: new Set(),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
this.walkSchema(rootSchema, normalizedEntry);
|
|
151
|
+
}
|
|
152
|
+
getVirtualFiles() {
|
|
153
|
+
return this.virtualFiles;
|
|
154
|
+
}
|
|
155
|
+
getAllCanonicalRefs() {
|
|
156
|
+
const result = [];
|
|
157
|
+
for (const file of this.virtualFiles.values()) {
|
|
158
|
+
if (file.fragments.size > 0) {
|
|
159
|
+
for (const fragment of file.fragments) {
|
|
160
|
+
result.push(`${file.sourceFile}${fragment}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
result.push(file.sourceFile);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
resolveCanonicalRef(canonicalRef) {
|
|
170
|
+
const parsed = (0, parseRef_1.parseRef)(canonicalRef);
|
|
171
|
+
const sourceFile = (0, pathHelpers_1.normalizeHelper)(parsed.filePath ?? '');
|
|
172
|
+
const file = this.virtualFiles.get(sourceFile);
|
|
173
|
+
if (!file)
|
|
174
|
+
return undefined;
|
|
175
|
+
return {
|
|
176
|
+
outputFile: file.outputFile,
|
|
177
|
+
fragment: parsed.fragment,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
83
180
|
}
|
|
84
181
|
exports.Context = Context;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAK/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,EAAE,CAsBjE"}
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getModels = getModels;
|
|
4
4
|
const getModelNameWithPrefix_1 = require("../../../utils/getModelNameWithPrefix");
|
|
5
|
-
const getRefFromSchema_1 = require("../../../utils/getRefFromSchema");
|
|
6
5
|
const modelHelpers_1 = require("../../../utils/modelHelpers");
|
|
7
6
|
const sortModelsByName_1 = require("../../../utils/sortModelsByName");
|
|
8
7
|
const unique_1 = require("../../../utils/unique");
|
|
9
8
|
function getModels(openApi) {
|
|
10
9
|
let models = [];
|
|
11
|
-
const listOfModelsRef =
|
|
10
|
+
const listOfModelsRef = this.context.getAllCanonicalRefs();
|
|
12
11
|
if (listOfModelsRef) {
|
|
13
12
|
for (const modelRef of listOfModelsRef) {
|
|
14
13
|
const definition = this.context.get(modelRef);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getType.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getType.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAK7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CA4C5E"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getType = getType;
|
|
4
|
+
const pathHelpers_1 = require("../../../../common/utils/pathHelpers");
|
|
4
5
|
const getMappedType_1 = require("../../../utils/getMappedType");
|
|
5
6
|
const getTypeName_1 = require("../../../utils/getTypeName");
|
|
6
7
|
const normalizeString_1 = require("../../../utils/normalizeString");
|
|
7
|
-
const resolveRefToImportPath_1 = require("../../../utils/resolveRefToImportPath");
|
|
8
8
|
const stripNamespace_1 = require("../../../utils/stripNamespace");
|
|
9
9
|
/**
|
|
10
10
|
* Parse any string value into a type object.
|
|
@@ -30,13 +30,19 @@ function getType(value, parentRef) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
else if (valueClean) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
/**
|
|
34
|
+
* canonicalValue может быть пустой строкой.
|
|
35
|
+
* В этом случае надо брать непосредственно normalizedValue - это относительный путь или фрагмент.
|
|
36
|
+
* Предполагаем, что в таком случае расчитывать нет нужды. Это путь от папки outputModels
|
|
37
|
+
*/
|
|
38
|
+
const canonicalValue = this.context.resolveCanonicalRef(normalizedValue);
|
|
39
|
+
let valuePath = valueClean;
|
|
40
|
+
if (canonicalValue) {
|
|
41
|
+
const refValuePath = canonicalValue?.fragment ? `${canonicalValue.outputFile}${canonicalValue.fragment}` : canonicalValue?.outputFile || '';
|
|
42
|
+
const cleanedRefValuePath = (0, stripNamespace_1.stripNamespace)(refValuePath);
|
|
43
|
+
valuePath = (0, pathHelpers_1.relativeHelper)(this.context.output?.outputModels, cleanedRefValuePath);
|
|
44
|
+
}
|
|
45
|
+
valuePath = !valuePath.startsWith('./') && !valuePath.startsWith('../') ? `./${valuePath}` : valuePath;
|
|
40
46
|
const type = this.getTypeNameByRef((0, getTypeName_1.getTypeName)(valueClean), parentRef);
|
|
41
47
|
const valueImportPath = !valuePath.startsWith('./') ? `./${valuePath}` : valuePath;
|
|
42
48
|
result.path = valuePath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAK/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,EAAE,CAsBjE"}
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getModels = getModels;
|
|
4
4
|
const getModelNameWithPrefix_1 = require("../../../utils/getModelNameWithPrefix");
|
|
5
|
-
const getRefFromSchema_1 = require("../../../utils/getRefFromSchema");
|
|
6
5
|
const modelHelpers_1 = require("../../../utils/modelHelpers");
|
|
7
6
|
const sortModelsByName_1 = require("../../../utils/sortModelsByName");
|
|
8
7
|
const unique_1 = require("../../../utils/unique");
|
|
9
8
|
function getModels(openApi) {
|
|
10
9
|
let models = [];
|
|
11
|
-
const listOfModelsRef =
|
|
10
|
+
const listOfModelsRef = this.context.getAllCanonicalRefs();
|
|
12
11
|
if (listOfModelsRef) {
|
|
13
12
|
for (const modelRef of listOfModelsRef) {
|
|
14
13
|
const definition = this.context.get(modelRef);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getType.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getType.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAK7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CA6C5E"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getType = getType;
|
|
4
|
+
const pathHelpers_1 = require("../../../../common/utils/pathHelpers");
|
|
4
5
|
const getMappedType_1 = require("../../../utils/getMappedType");
|
|
5
6
|
const getTypeName_1 = require("../../../utils/getTypeName");
|
|
6
7
|
const normalizeString_1 = require("../../../utils/normalizeString");
|
|
7
|
-
const resolveRefToImportPath_1 = require("../../../utils/resolveRefToImportPath");
|
|
8
8
|
const stripNamespace_1 = require("../../../utils/stripNamespace");
|
|
9
9
|
/**
|
|
10
10
|
* Parse any string value into a type object.
|
|
@@ -30,13 +30,19 @@ function getType(value, parentRef) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
else if (valueClean) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
/**
|
|
34
|
+
* canonicalValue может быть пустой строкой.
|
|
35
|
+
* В этом случае надо брать непосредственно normalizedValue - это относительный путь или фрагмент.
|
|
36
|
+
* Предполагаем, что в таком случае расчитывать нет нужды. Это путь от папки outputModels
|
|
37
|
+
*/
|
|
38
|
+
const canonicalValue = this.context.resolveCanonicalRef(normalizedValue);
|
|
39
|
+
let valuePath = valueClean;
|
|
40
|
+
if (canonicalValue) {
|
|
41
|
+
const refValuePath = canonicalValue?.fragment ? `${canonicalValue.outputFile}${canonicalValue.fragment}` : canonicalValue?.outputFile || '';
|
|
42
|
+
const cleanedRefValuePath = (0, stripNamespace_1.stripNamespace)(refValuePath);
|
|
43
|
+
valuePath = (0, pathHelpers_1.relativeHelper)(this.context.output?.outputModels, cleanedRefValuePath);
|
|
44
|
+
}
|
|
45
|
+
valuePath = !valuePath.startsWith('./') && !valuePath.startsWith('../') ? `./${valuePath}` : valuePath;
|
|
40
46
|
const type = this.getTypeNameByRef((0, getTypeName_1.getTypeName)(valueClean), parentRef);
|
|
41
47
|
const valueImportPath = !valuePath.startsWith('./') ? `./${valuePath}` : valuePath;
|
|
42
48
|
result.path = valuePath;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { Context } from '../Context';
|
|
2
2
|
import { CommonOpenApi } from '../types/shared/CommonOpenApi.model';
|
|
3
|
-
/**
|
|
4
|
-
* Load and parse te open api spec. If the file extension is ".yml" or ".yaml"
|
|
5
|
-
* we will try to parse the file as a YAML spec, otherwise we will fallback
|
|
6
|
-
* on parsing the file as JSON.
|
|
7
|
-
* @param input
|
|
8
|
-
*/
|
|
9
3
|
export declare function getOpenApiSpec(context: Context, input: string): Promise<CommonOpenApi>;
|
|
10
4
|
//# sourceMappingURL=getOpenApiSpec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOpenApiSpec.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOpenApiSpec.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"getOpenApiSpec.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOpenApiSpec.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAEpE,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAyB5F"}
|
|
@@ -7,33 +7,23 @@ exports.getOpenApiSpec = getOpenApiSpec;
|
|
|
7
7
|
const swagger_parser_1 = __importDefault(require("@apidevtools/swagger-parser"));
|
|
8
8
|
const fileSystemHelpers_1 = require("../../common/utils/fileSystemHelpers");
|
|
9
9
|
const pathHelpers_1 = require("../../common/utils/pathHelpers");
|
|
10
|
-
const normalizeAllRefs_1 = require("./normalizeAllRefs");
|
|
11
|
-
/**
|
|
12
|
-
* Load and parse te open api spec. If the file extension is ".yml" or ".yaml"
|
|
13
|
-
* we will try to parse the file as a YAML spec, otherwise we will fallback
|
|
14
|
-
* on parsing the file as JSON.
|
|
15
|
-
* @param input
|
|
16
|
-
*/
|
|
17
10
|
async function getOpenApiSpec(context, input) {
|
|
18
11
|
const absoluteInput = (0, pathHelpers_1.resolveHelper)(process.cwd(), input);
|
|
19
12
|
if (!input) {
|
|
20
|
-
throw new Error(`
|
|
13
|
+
throw new Error(`OpenAPI spec path is empty`);
|
|
21
14
|
}
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
24
|
-
throw new Error(`
|
|
15
|
+
const exists = await fileSystemHelpers_1.fileSystemHelpers.exists(absoluteInput);
|
|
16
|
+
if (!exists) {
|
|
17
|
+
throw new Error(`OpenAPI spec not found: ${absoluteInput}`);
|
|
25
18
|
}
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const raw =
|
|
31
|
-
if (!raw || typeof raw !== 'object'
|
|
32
|
-
throw new Error(`
|
|
19
|
+
const parser = new swagger_parser_1.default();
|
|
20
|
+
const resolved = await parser.resolve(absoluteInput);
|
|
21
|
+
context.addRefs(resolved);
|
|
22
|
+
// Получить основную схему
|
|
23
|
+
const raw = resolved.get(absoluteInput);
|
|
24
|
+
if (!raw || typeof raw !== 'object') {
|
|
25
|
+
throw new Error(`Invalid OpenAPI schema at ${absoluteInput}`);
|
|
33
26
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const normalizedSchema = (0, normalizeAllRefs_1.normalizeAllRefs)(mainSchema, context, absoluteInput);
|
|
37
|
-
// The schema is already fully normalized, so we can return it directly
|
|
38
|
-
return normalizedSchema;
|
|
27
|
+
context.initializeVirtualFileMap(raw, absoluteInput);
|
|
28
|
+
return raw;
|
|
39
29
|
}
|
|
@@ -17,7 +17,7 @@ function stripNamespace(value) {
|
|
|
17
17
|
const foundFile = value.match(/^(.*)#/);
|
|
18
18
|
const directoryName = foundFile ? (0, pathHelpers_1.dirNameHelper)(foundFile[1]) : (0, pathHelpers_1.dirNameHelper)(value);
|
|
19
19
|
const extName = (0, path_1.extname)(value);
|
|
20
|
-
const baseName = extName
|
|
20
|
+
const baseName = extName ? (0, getClassName_1.getClassName)((0, path_1.basename)(value, extName)) : (0, getClassName_1.getClassName)((0, path_1.basename)(value));
|
|
21
21
|
return directoryName ? (0, pathHelpers_1.joinHelper)(directoryName, baseName) : baseName;
|
|
22
22
|
}
|
|
23
23
|
const clearValue = value
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-openapi-codegen",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.7",
|
|
4
4
|
"description": "Library that generates Typescript clients based on the OpenAPI specification. It bases on openapi-typescript-codegen",
|
|
5
5
|
"author": "Alexey Zverev",
|
|
6
6
|
"homepage": "https://github.com/ozonophore/openapi-codegen.git",
|
|
@@ -105,8 +105,6 @@
|
|
|
105
105
|
"@typescript-eslint/eslint-plugin": "^8.34.1",
|
|
106
106
|
"@typescript-eslint/parser": "^8.34.1",
|
|
107
107
|
"abort-controller": "^3.0.0",
|
|
108
|
-
"ajv": "^8.17.1",
|
|
109
|
-
"ajv-formats": "^3.0.1",
|
|
110
108
|
"axios": "1.8.2",
|
|
111
109
|
"codecov": "3.8.3",
|
|
112
110
|
"eslint": "^9.29.0",
|
|
@@ -128,16 +126,12 @@
|
|
|
128
126
|
"ts-prune": "^0.10.3",
|
|
129
127
|
"tsx": "^4.20.3",
|
|
130
128
|
"typescript": "^5.8.3",
|
|
131
|
-
"yup": "^1.7.1",
|
|
132
129
|
"zod": "^4.3.2"
|
|
133
130
|
},
|
|
134
131
|
"peerDependencies": {
|
|
135
|
-
"ajv": ">=8.17.1",
|
|
136
|
-
"ajv-formats": ">=3.0.1",
|
|
137
132
|
"axios": ">=1.8.2 <=1.9.0",
|
|
138
133
|
"joi": ">=17.13.3",
|
|
139
134
|
"prettier": "3.4.2>= <=3.5.3",
|
|
140
|
-
"yup": ">=1.7.1",
|
|
141
135
|
"zod": ">=4.3.2"
|
|
142
136
|
}
|
|
143
137
|
}
|