ts-openapi-codegen 2.0.0-beta.0 → 2.0.0-beta.1
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 +74 -0
- package/README.rus.md +73 -0
- package/dist/common/TRawOptions.d.ts.map +1 -1
- package/dist/core/__tests__/WriteClient.test.js +2 -0
- package/dist/core/utils/__mocks__/templates.d.ts +3 -0
- package/dist/core/utils/__mocks__/templates.d.ts.map +1 -0
- package/dist/core/utils/__mocks__/templates.js +29 -0
- package/dist/core/utils/__tests__/writeClientCore.test.js +2 -25
- package/dist/core/utils/__tests__/writeClientFullIndex.test.js +2 -25
- package/dist/core/utils/__tests__/writeClientModels.test.js +2 -25
- package/dist/core/utils/__tests__/writeClientSchemas.test.js +2 -25
- package/dist/core/utils/__tests__/writeClientServices.test.js +2 -25
- package/dist/core/utils/registerHandlebarTemplates.d.ts +2 -0
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.js +4 -0
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +3 -0
- package/dist/templatesCompiled/client/core/legacy-request-adapter.d.ts +8 -0
- package/dist/templatesCompiled/client/core/legacy-request-adapter.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/legacy-request-adapter.js +18 -0
- package/dist/templatesCompiled/client/core/request-executor.d.ts +7 -0
- package/dist/templatesCompiled/client/core/request-executor.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/request-executor.js +11 -0
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +46 -50
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -510,6 +510,80 @@ export function request<T>(config: TOpenAPIConfig, options: ApiRequestOptions):
|
|
|
510
510
|
}
|
|
511
511
|
```
|
|
512
512
|
|
|
513
|
+
### Custom Request Executor
|
|
514
|
+
|
|
515
|
+
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.
|
|
516
|
+
|
|
517
|
+
**Using a custom RequestExecutor:**
|
|
518
|
+
|
|
519
|
+
You can create your own `RequestExecutor` implementation:
|
|
520
|
+
|
|
521
|
+
```ts
|
|
522
|
+
import type { RequestExecutor, RequestConfig } from './generated/core/request-executor';
|
|
523
|
+
import { SimpleService } from './generated/services/SimpleService';
|
|
524
|
+
|
|
525
|
+
// Define your custom options type (optional)
|
|
526
|
+
interface MyCustomOptions {
|
|
527
|
+
timeout?: number;
|
|
528
|
+
retries?: number;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// Create a custom executor
|
|
532
|
+
const customExecutor: RequestExecutor<MyCustomOptions> = {
|
|
533
|
+
async request<TResponse>(config: RequestConfig, options?: MyCustomOptions): Promise<TResponse> {
|
|
534
|
+
// Your custom request logic here
|
|
535
|
+
const response = await fetch(config.url, {
|
|
536
|
+
method: config.method,
|
|
537
|
+
headers: config.headers,
|
|
538
|
+
body: config.body ? JSON.stringify(config.body) : undefined,
|
|
539
|
+
signal: options?.timeout ? AbortSignal.timeout(options.timeout) : undefined,
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
if (!response.ok) {
|
|
543
|
+
throw new Error(`Request failed: ${response.statusText}`);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
return response.json();
|
|
547
|
+
},
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
// Use it with generated services
|
|
551
|
+
const simpleService = new SimpleService<MyCustomOptions>(customExecutor);
|
|
552
|
+
await simpleService.getCallWithoutParametersAndResponse({ timeout: 5000, retries: 3 });
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
**Using legacy request adapter:**
|
|
556
|
+
|
|
557
|
+
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:
|
|
558
|
+
|
|
559
|
+
```ts
|
|
560
|
+
import { createLegacyExecutor } from './generated/core/legacy-request-adapter';
|
|
561
|
+
import { OpenAPI } from './generated/core/OpenAPI';
|
|
562
|
+
import { SimpleService } from './generated/services/SimpleService';
|
|
563
|
+
|
|
564
|
+
// The legacy adapter wraps your existing request function
|
|
565
|
+
const executor = createLegacyExecutor(OpenAPI);
|
|
566
|
+
|
|
567
|
+
// Optionally, you can map custom options to ApiRequestOptions
|
|
568
|
+
interface XHROptions {
|
|
569
|
+
timeout?: number;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
const executorWithOptions = createLegacyExecutor<XHROptions>(OpenAPI, (options) => {
|
|
573
|
+
// Map your custom options to ApiRequestOptions if needed
|
|
574
|
+
return {
|
|
575
|
+
// Add any ApiRequestOptions fields based on options
|
|
576
|
+
};
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
// Use with services
|
|
580
|
+
const simpleService = new SimpleService(executor);
|
|
581
|
+
await simpleService.getCallWithoutParametersAndResponse();
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
**Note:** The `--request` option still works for customizing the core `request` function. The generated
|
|
585
|
+
`legacy-request-adapter` will automatically use your custom request implementation when creating the adapter.
|
|
586
|
+
|
|
513
587
|
### Sorting strategy for function arguments `--sortByRequired`
|
|
514
588
|
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.
|
|
515
589
|
|
package/README.rus.md
CHANGED
|
@@ -509,6 +509,79 @@ export function request<T>(config: TOpenAPIConfig, options: ApiRequestOptions):
|
|
|
509
509
|
}
|
|
510
510
|
```
|
|
511
511
|
|
|
512
|
+
### Пользовательский Request Executor
|
|
513
|
+
|
|
514
|
+
Начиная с версии 2.0.0, сгенерированные сервисы используют интерфейс `RequestExecutor` вместо прямых вызовов core-функции `request`. Это позволяет вам предоставить свою собственную реализацию запросов или адаптировать существующие.
|
|
515
|
+
|
|
516
|
+
**Использование пользовательского RequestExecutor:**
|
|
517
|
+
|
|
518
|
+
Вы можете создать свою собственную реализацию `RequestExecutor`:
|
|
519
|
+
|
|
520
|
+
```ts
|
|
521
|
+
import type { RequestExecutor, RequestConfig } from './generated/core/request-executor';
|
|
522
|
+
import { SimpleService } from './generated/services/SimpleService';
|
|
523
|
+
|
|
524
|
+
// Определите свой тип опций (опционально)
|
|
525
|
+
interface MyCustomOptions {
|
|
526
|
+
timeout?: number;
|
|
527
|
+
retries?: number;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// Создайте пользовательский executor
|
|
531
|
+
const customExecutor: RequestExecutor<MyCustomOptions> = {
|
|
532
|
+
async request<TResponse>(config: RequestConfig, options?: MyCustomOptions): Promise<TResponse> {
|
|
533
|
+
// Ваша пользовательская логика запросов здесь
|
|
534
|
+
const response = await fetch(config.url, {
|
|
535
|
+
method: config.method,
|
|
536
|
+
headers: config.headers,
|
|
537
|
+
body: config.body ? JSON.stringify(config.body) : undefined,
|
|
538
|
+
signal: options?.timeout ? AbortSignal.timeout(options.timeout) : undefined,
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
if (!response.ok) {
|
|
542
|
+
throw new Error(`Request failed: ${response.statusText}`);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
return response.json();
|
|
546
|
+
},
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
// Используйте его со сгенерированными сервисами
|
|
550
|
+
const simpleService = new SimpleService<MyCustomOptions>(customExecutor);
|
|
551
|
+
await simpleService.getCallWithoutParametersAndResponse({ timeout: 5000, retries: 3 });
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
**Использование legacy request adapter:**
|
|
555
|
+
|
|
556
|
+
Если у вас есть существующий пользовательский файл `request` (указанный через опцию `--request`), вы можете использовать хелпер `createLegacyExecutor` для адаптации его к новому интерфейсу `RequestExecutor`:
|
|
557
|
+
|
|
558
|
+
```ts
|
|
559
|
+
import { createLegacyExecutor } from './generated/core/legacy-request-adapter';
|
|
560
|
+
import { OpenAPI } from './generated/core/OpenAPI';
|
|
561
|
+
import { SimpleService } from './generated/services/SimpleService';
|
|
562
|
+
|
|
563
|
+
// Legacy адаптер оборачивает вашу существующую функцию request
|
|
564
|
+
const executor = createLegacyExecutor(OpenAPI);
|
|
565
|
+
|
|
566
|
+
// Опционально, вы можете мапить пользовательские опции в ApiRequestOptions
|
|
567
|
+
interface XHROptions {
|
|
568
|
+
timeout?: number;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const executorWithOptions = createLegacyExecutor<XHROptions>(OpenAPI, (options) => {
|
|
572
|
+
// Мапьте ваши пользовательские опции в ApiRequestOptions при необходимости
|
|
573
|
+
return {
|
|
574
|
+
// Добавьте любые поля ApiRequestOptions на основе options
|
|
575
|
+
};
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
// Используйте со сервисами
|
|
579
|
+
const simpleService = new SimpleService(executor);
|
|
580
|
+
await simpleService.getCallWithoutParametersAndResponse();
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
**Примечание:** Опция --request по-прежнему работает для кастомизации core-функции request. Сгенерированный legacy-request-adapter автоматически будет использовать вашу пользовательскую реализацию request при создании адаптера.
|
|
584
|
+
|
|
512
585
|
### Стратегия сортировки аргументов функций `--sortByRequired`
|
|
513
586
|
По умолчанию генератор OpenAPI сортирует параметры сервисных функций согласно упрощенной схеме. Если вам нужна более строгая опция сортировки, используйте флаг `--sortByRequired`. Упрощенная опция сортировки похожа на ту, что использовалась в версии 0.2.3 генератора OpenAPI. Этот флаг позволяет обновиться до новой версии генератора, если вы "застряли" на версии 0.2.3.
|
|
514
587
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TRawOptions.d.ts","sourceRoot":"","sources":["../../src/common/TRawOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEhD,KAAK,WAAW,GAAG;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,
|
|
1
|
+
{"version":3,"file":"TRawOptions.d.ts","sourceRoot":"","sources":["../../src/common/TRawOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEhD,KAAK,WAAW,GAAG;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAEtD,MAAM,MAAM,kBAAkB,GAAG;KAC5B,CAAC,IAAI,MAAM,YAAY,CAAC,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAC5D,CAAC"}
|
|
@@ -51,6 +51,8 @@ const WriteClient_1 = require("../WriteClient");
|
|
|
51
51
|
request: () => 'request',
|
|
52
52
|
cancelablePromise: () => 'cancelablePromise',
|
|
53
53
|
httpStatusCode: () => 'httpStatusCode',
|
|
54
|
+
legacyRequestAdapter: () => 'legacyRequestAdapter',
|
|
55
|
+
requestExecutor: () => 'requestExecutor',
|
|
54
56
|
},
|
|
55
57
|
};
|
|
56
58
|
const outputPaths = (0, getOutputPaths_1.getOutputPaths)({ output: './dist' });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__mocks__/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,eAAO,MAAM,SAAS,EAAE,SAyBvB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.templates = void 0;
|
|
4
|
+
exports.templates = {
|
|
5
|
+
indexes: {
|
|
6
|
+
full: () => 'fullIndex',
|
|
7
|
+
simple: () => 'simpleIndex',
|
|
8
|
+
core: () => 'coreIndex',
|
|
9
|
+
models: () => 'modelsIndex',
|
|
10
|
+
schemas: () => 'schemasIndex',
|
|
11
|
+
services: () => 'servicesIndex',
|
|
12
|
+
},
|
|
13
|
+
exports: {
|
|
14
|
+
model: () => 'model',
|
|
15
|
+
schema: () => 'schema',
|
|
16
|
+
service: () => 'service',
|
|
17
|
+
},
|
|
18
|
+
core: {
|
|
19
|
+
settings: () => 'settings',
|
|
20
|
+
apiError: () => 'apiError',
|
|
21
|
+
apiRequestOptions: () => 'apiRequestOptions',
|
|
22
|
+
apiResult: () => 'apiResult',
|
|
23
|
+
request: () => 'request',
|
|
24
|
+
cancelablePromise: () => 'cancelablePromise',
|
|
25
|
+
httpStatusCode: () => 'httpStatusCode',
|
|
26
|
+
legacyRequestAdapter: () => 'legacyRequestAdapter',
|
|
27
|
+
requestExecutor: () => 'requestExecutor',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -8,6 +8,7 @@ const node_test_1 = require("node:test");
|
|
|
8
8
|
const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
|
|
9
9
|
const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
|
|
10
10
|
const WriteClient_1 = require("../../WriteClient");
|
|
11
|
+
const templates_1 = require("../__mocks__/templates");
|
|
11
12
|
(0, node_test_1.describe)('@unit: writeClientCore', () => {
|
|
12
13
|
(0, node_test_1.test)('writes to filesystem', async () => {
|
|
13
14
|
const writeFileCalls = [];
|
|
@@ -22,33 +23,9 @@ const WriteClient_1 = require("../../WriteClient");
|
|
|
22
23
|
models: [],
|
|
23
24
|
services: [],
|
|
24
25
|
};
|
|
25
|
-
const templates = {
|
|
26
|
-
indexes: {
|
|
27
|
-
full: () => 'fullIndex',
|
|
28
|
-
simple: () => 'simpleIndex',
|
|
29
|
-
core: () => 'coreIndex',
|
|
30
|
-
models: () => 'modelsIndex',
|
|
31
|
-
schemas: () => 'schemasIndex',
|
|
32
|
-
services: () => 'servicesIndex',
|
|
33
|
-
},
|
|
34
|
-
exports: {
|
|
35
|
-
model: () => 'model',
|
|
36
|
-
schema: () => 'schema',
|
|
37
|
-
service: () => 'service',
|
|
38
|
-
},
|
|
39
|
-
core: {
|
|
40
|
-
settings: () => 'settings',
|
|
41
|
-
apiError: () => 'apiError',
|
|
42
|
-
apiRequestOptions: () => 'apiRequestOptions',
|
|
43
|
-
apiResult: () => 'apiResult',
|
|
44
|
-
request: () => 'request',
|
|
45
|
-
cancelablePromise: () => 'cancelablePromise',
|
|
46
|
-
httpStatusCode: () => 'httpStatusCode',
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
26
|
const useCancelableRequest = true;
|
|
50
27
|
const writeClient = new WriteClient_1.WriteClient();
|
|
51
|
-
await writeClient.writeClientCore({ client, templates, outputCorePath: '/', httpClient: HttpClient_enum_1.HttpClient.FETCH, useCancelableRequest });
|
|
28
|
+
await writeClient.writeClientCore({ client, templates: templates_1.templates, outputCorePath: '/', httpClient: HttpClient_enum_1.HttpClient.FETCH, useCancelableRequest });
|
|
52
29
|
node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('OpenAPI.ts') && content.toString().includes('settings')), 'Expected writeFile to be called with settings content for OpenAPI.ts');
|
|
53
30
|
node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('ApiError.ts') && content.toString().includes('apiError')), 'Expected writeFile to be called with apiError content for ApiError.ts');
|
|
54
31
|
node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('ApiRequestOptions.ts') && content.toString().includes('apiRequestOptions')), 'Expected writeFile to be called with apiRequestOptions content for ApiRequestOptions.ts');
|
|
@@ -7,6 +7,7 @@ const node_assert_1 = __importDefault(require("node:assert"));
|
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
8
|
const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
|
|
9
9
|
const WriteClient_1 = require("../../WriteClient");
|
|
10
|
+
const templates_1 = require("../__mocks__/templates");
|
|
10
11
|
(0, node_test_1.describe)('@unit: writeClientFullIndex', () => {
|
|
11
12
|
(0, node_test_1.test)('writes to filesystem', async () => {
|
|
12
13
|
const writeFileCalls = [];
|
|
@@ -15,32 +16,8 @@ const WriteClient_1 = require("../../WriteClient");
|
|
|
15
16
|
fileSystemHelpers_1.fileSystemHelpers.writeFile = async (path, content) => {
|
|
16
17
|
writeFileCalls.push([path, content]);
|
|
17
18
|
};
|
|
18
|
-
const templates = {
|
|
19
|
-
indexes: {
|
|
20
|
-
full: () => 'fullIndex',
|
|
21
|
-
simple: () => 'simpleIndex',
|
|
22
|
-
core: () => 'coreIndex',
|
|
23
|
-
models: () => 'modelsIndex',
|
|
24
|
-
schemas: () => 'schemasIndex',
|
|
25
|
-
services: () => 'servicesIndex',
|
|
26
|
-
},
|
|
27
|
-
exports: {
|
|
28
|
-
model: () => 'model',
|
|
29
|
-
schema: () => 'schema',
|
|
30
|
-
service: () => 'service',
|
|
31
|
-
},
|
|
32
|
-
core: {
|
|
33
|
-
settings: () => 'settings',
|
|
34
|
-
apiError: () => 'apiError',
|
|
35
|
-
apiRequestOptions: () => 'apiRequestOptions',
|
|
36
|
-
apiResult: () => 'apiResult',
|
|
37
|
-
request: () => 'request',
|
|
38
|
-
cancelablePromise: () => 'cancelablePromise',
|
|
39
|
-
httpStatusCode: () => 'httpStatusCode',
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
19
|
const writeClient = new WriteClient_1.WriteClient();
|
|
43
|
-
await writeClient.writeClientFullIndex({ templates, outputPath: '/', core: [], models: [], schemas: [], services: [] });
|
|
20
|
+
await writeClient.writeClientFullIndex({ templates: templates_1.templates, outputPath: '/', core: [], models: [], schemas: [], services: [] });
|
|
44
21
|
node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('index.ts') && content.toString().includes('fullIndex')), 'Expected writeFile to be called with index content for index.ts');
|
|
45
22
|
// Restoring the original function
|
|
46
23
|
fileSystemHelpers_1.fileSystemHelpers.writeFile = originalWriteFile;
|
|
@@ -8,6 +8,7 @@ const node_test_1 = require("node:test");
|
|
|
8
8
|
const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
|
|
9
9
|
const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
|
|
10
10
|
const WriteClient_1 = require("../../WriteClient");
|
|
11
|
+
const templates_1 = require("../__mocks__/templates");
|
|
11
12
|
(0, node_test_1.describe)('@unit: writeClientModels', () => {
|
|
12
13
|
(0, node_test_1.test)('writes to filesystem', async () => {
|
|
13
14
|
const writeFileCalls = [];
|
|
@@ -37,34 +38,10 @@ const WriteClient_1 = require("../../WriteClient");
|
|
|
37
38
|
alias: '',
|
|
38
39
|
},
|
|
39
40
|
];
|
|
40
|
-
const templates = {
|
|
41
|
-
indexes: {
|
|
42
|
-
full: () => 'fullIndex',
|
|
43
|
-
simple: () => 'simpleIndex',
|
|
44
|
-
core: () => 'coreIndex',
|
|
45
|
-
models: () => 'modelsIndex',
|
|
46
|
-
schemas: () => 'schemasIndex',
|
|
47
|
-
services: () => 'servicesIndex',
|
|
48
|
-
},
|
|
49
|
-
exports: {
|
|
50
|
-
model: () => 'model',
|
|
51
|
-
schema: () => 'schema',
|
|
52
|
-
service: () => 'service',
|
|
53
|
-
},
|
|
54
|
-
core: {
|
|
55
|
-
settings: () => 'settings',
|
|
56
|
-
apiError: () => 'apiError',
|
|
57
|
-
apiRequestOptions: () => 'apiRequestOptions',
|
|
58
|
-
apiResult: () => 'apiResult',
|
|
59
|
-
request: () => 'request',
|
|
60
|
-
cancelablePromise: () => 'cancelablePromise',
|
|
61
|
-
httpStatusCode: () => 'httpStatusCode',
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
41
|
const writeClient = new WriteClient_1.WriteClient();
|
|
65
42
|
await writeClient.writeClientModels({
|
|
66
43
|
models,
|
|
67
|
-
templates,
|
|
44
|
+
templates: templates_1.templates,
|
|
68
45
|
outputModelsPath: '/',
|
|
69
46
|
httpClient: HttpClient_enum_1.HttpClient.FETCH,
|
|
70
47
|
useUnionTypes: false,
|
|
@@ -8,6 +8,7 @@ const node_test_1 = require("node:test");
|
|
|
8
8
|
const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
|
|
9
9
|
const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
|
|
10
10
|
const WriteClient_1 = require("../../WriteClient");
|
|
11
|
+
const templates_1 = require("../__mocks__/templates");
|
|
11
12
|
(0, node_test_1.describe)('@unit: writeClientSchemas', () => {
|
|
12
13
|
(0, node_test_1.test)('writes to filesystem', async () => {
|
|
13
14
|
const writeFileCalls = [];
|
|
@@ -37,34 +38,10 @@ const WriteClient_1 = require("../../WriteClient");
|
|
|
37
38
|
properties: [],
|
|
38
39
|
},
|
|
39
40
|
];
|
|
40
|
-
const templates = {
|
|
41
|
-
indexes: {
|
|
42
|
-
full: () => 'fullIndex',
|
|
43
|
-
simple: () => 'simpleIndex',
|
|
44
|
-
core: () => 'coreIndex',
|
|
45
|
-
models: () => 'modelsIndex',
|
|
46
|
-
schemas: () => 'schemasIndex',
|
|
47
|
-
services: () => 'servicesIndex',
|
|
48
|
-
},
|
|
49
|
-
exports: {
|
|
50
|
-
model: () => 'model',
|
|
51
|
-
schema: () => 'schema',
|
|
52
|
-
service: () => 'service',
|
|
53
|
-
},
|
|
54
|
-
core: {
|
|
55
|
-
settings: () => 'settings',
|
|
56
|
-
apiError: () => 'apiError',
|
|
57
|
-
apiRequestOptions: () => 'apiRequestOptions',
|
|
58
|
-
apiResult: () => 'apiResult',
|
|
59
|
-
request: () => 'request',
|
|
60
|
-
cancelablePromise: () => 'cancelablePromise',
|
|
61
|
-
httpStatusCode: () => 'httpStatusCode',
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
41
|
const writeClient = new WriteClient_1.WriteClient();
|
|
65
42
|
await writeClient.writeClientSchemas({
|
|
66
43
|
models,
|
|
67
|
-
templates,
|
|
44
|
+
templates: templates_1.templates,
|
|
68
45
|
outputSchemasPath: '/',
|
|
69
46
|
httpClient: HttpClient_enum_1.HttpClient.FETCH,
|
|
70
47
|
useUnionTypes: false,
|
|
@@ -8,6 +8,7 @@ const node_test_1 = require("node:test");
|
|
|
8
8
|
const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
|
|
9
9
|
const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
|
|
10
10
|
const WriteClient_1 = require("../../WriteClient");
|
|
11
|
+
const templates_1 = require("../__mocks__/templates");
|
|
11
12
|
(0, node_test_1.describe)('@unit: writeClientServices', () => {
|
|
12
13
|
(0, node_test_1.test)('writes to filesystem', async () => {
|
|
13
14
|
const writeFileCalls = [];
|
|
@@ -24,34 +25,10 @@ const WriteClient_1 = require("../../WriteClient");
|
|
|
24
25
|
imports: [],
|
|
25
26
|
},
|
|
26
27
|
];
|
|
27
|
-
const templates = {
|
|
28
|
-
indexes: {
|
|
29
|
-
full: () => 'fullIndex',
|
|
30
|
-
simple: () => 'simpleIndex',
|
|
31
|
-
core: () => 'coreIndex',
|
|
32
|
-
models: () => 'modelsIndex',
|
|
33
|
-
schemas: () => 'schemasIndex',
|
|
34
|
-
services: () => 'servicesIndex',
|
|
35
|
-
},
|
|
36
|
-
exports: {
|
|
37
|
-
model: () => 'model',
|
|
38
|
-
schema: () => 'schema',
|
|
39
|
-
service: () => 'service',
|
|
40
|
-
},
|
|
41
|
-
core: {
|
|
42
|
-
settings: () => 'settings',
|
|
43
|
-
apiError: () => 'apiError',
|
|
44
|
-
apiRequestOptions: () => 'apiRequestOptions',
|
|
45
|
-
apiResult: () => 'apiResult',
|
|
46
|
-
request: () => 'request',
|
|
47
|
-
cancelablePromise: () => 'cancelablePromise',
|
|
48
|
-
httpStatusCode: () => 'httpStatusCode',
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
28
|
const writeClient = new WriteClient_1.WriteClient();
|
|
52
29
|
await writeClient.writeClientServices({
|
|
53
30
|
services,
|
|
54
|
-
templates,
|
|
31
|
+
templates: templates_1.templates,
|
|
55
32
|
outputPaths: {
|
|
56
33
|
outputCore: '/',
|
|
57
34
|
outputModels: '/',
|
|
@@ -22,6 +22,8 @@ export interface Templates {
|
|
|
22
22
|
request: Handlebars.TemplateDelegate;
|
|
23
23
|
cancelablePromise: Handlebars.TemplateDelegate;
|
|
24
24
|
httpStatusCode: Handlebars.TemplateDelegate;
|
|
25
|
+
requestExecutor: Handlebars.TemplateDelegate;
|
|
26
|
+
legacyRequestAdapter: Handlebars.TemplateDelegate;
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAyFjD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE;QACL,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACzC,CAAA;IACD,OAAO,EAAE;QACL,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACnC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACxC,CAAC;IACF,IAAI,EAAE;QACF,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC5C,eAAe,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC7C,oBAAoB,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACrD,CAAC;CACL;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CA8GnI"}
|
|
@@ -77,6 +77,8 @@ const sendRequest_3 = __importDefault(require("../../templatesCompiled/client/co
|
|
|
77
77
|
const OpenAPI_1 = __importDefault(require("../../templatesCompiled/client/core/OpenAPI"));
|
|
78
78
|
const CancelablePromise_1 = __importDefault(require("../../templatesCompiled/client/core/CancelablePromise"));
|
|
79
79
|
const request_4 = __importDefault(require("../../templatesCompiled/client/core/request"));
|
|
80
|
+
const request_executor_1 = __importDefault(require("../../templatesCompiled/client/core/request-executor"));
|
|
81
|
+
const legacy_request_adapter_1 = __importDefault(require("../../templatesCompiled/client/core/legacy-request-adapter"));
|
|
80
82
|
const getHeaders_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/getHeaders"));
|
|
81
83
|
const getRequestBody_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/getRequestBody"));
|
|
82
84
|
const getResponseBody_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/getResponseBody"));
|
|
@@ -153,6 +155,8 @@ function registerHandlebarTemplates(root) {
|
|
|
153
155
|
request: Handlebars.template(request_4.default),
|
|
154
156
|
cancelablePromise: Handlebars.template(CancelablePromise_1.default),
|
|
155
157
|
httpStatusCode: Handlebars.template(HttpStatusCode_1.default),
|
|
158
|
+
requestExecutor: Handlebars.template(request_executor_1.default),
|
|
159
|
+
legacyRequestAdapter: Handlebars.template(legacy_request_adapter_1.default),
|
|
156
160
|
},
|
|
157
161
|
};
|
|
158
162
|
// Partials for the generations of the models, services, etc.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeClientCore.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientCore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD;;;;;;;GAOG;AACH,UAAU,gBAAgB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"writeClientCore.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientCore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD;;;;;;;GAOG;AACH,UAAU,gBAAgB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCjG"}
|
|
@@ -31,6 +31,9 @@ async function writeClientCore(options) {
|
|
|
31
31
|
}
|
|
32
32
|
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'HttpStatusCode.ts'), templates.core.httpStatusCode({}));
|
|
33
33
|
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'request.ts'), templates.core.request(context));
|
|
34
|
+
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'request-executor.ts'), templates.core.requestExecutor({}));
|
|
35
|
+
// TODO: Добавлять только, если не выбран custom-ный request
|
|
36
|
+
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'legacy-request-adapter.ts'), templates.core.legacyRequestAdapter({}));
|
|
34
37
|
if (request) {
|
|
35
38
|
const requestFile = (0, pathHelpers_1.resolveHelper)(process.cwd(), request);
|
|
36
39
|
const requestFileExists = await fileSystemHelpers_1.fileSystemHelpers.exists(requestFile);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
compiler: (string | number)[];
|
|
3
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
4
|
+
usePartial: boolean;
|
|
5
|
+
useData: boolean;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=legacy-request-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-request-adapter.d.ts","sourceRoot":"","sources":["../../../../src/templatesCompiled/client/core/legacy-request-adapter.ts"],"names":[],"mappings":";;;;;;AAMA,wBAUmC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// This is an automatically generated file for the hbs template.
|
|
4
|
+
// You don't need to change it, run npm run build:hbs to update it.
|
|
5
|
+
/* istanbul ignore file */
|
|
6
|
+
/* tslint: disable */
|
|
7
|
+
/* eslint: disable */
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
exports.default = { "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
|
|
10
|
+
var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
|
|
12
|
+
return parent[propertyName];
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
16
|
+
return ((stack1 = container.invokePartial(lookupProperty(partials, "header"), depth0, { "name": "header", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
17
|
+
+ "\nimport type { RequestExecutor, RequestConfig } from './request-executor';\nimport type { ApiRequestOptions } from './ApiRequestOptions';\nimport type { TOpenAPIConfig } from './OpenAPI';\nimport { OpenAPI } from './OpenAPI';\nimport { request as __request } from './request';\n\n/**\n * Legacy RequestExecutor-адаптер поверх существующего request(ApiRequestOptions, OpenAPI).\n *\n * TOptions — тип рантайм-опций транспорта (IXHROptions, IFetchOptions и т.п.).\n * mapOptions — опциональная функция, которая мапит TOptions → часть ApiRequestOptions.\n */\nexport function createLegacyExecutor<TOptions = unknown>(\n openApiConfig: TOpenAPIConfig = OpenAPI,\n mapOptions?: (options: TOptions | undefined) => Partial<ApiRequestOptions>,\n): RequestExecutor<TOptions> {\n return {\n request<TResponse>(config: RequestConfig, options?: TOptions): Promise<TResponse> {\n const baseOptions: ApiRequestOptions = {\n method: config.method as ApiRequestOptions['method'],\n path: config.url, // RequestConfig.url → ApiRequestOptions.path\n headers: config.headers,\n query: config.query,\n body: config.body,\n };\n\n const mergedOptions: ApiRequestOptions = {\n ...baseOptions,\n ...(mapOptions ? mapOptions(options) : {}),\n };\n\n return __request<TResponse>(mergedOptions, openApiConfig);\n },\n };\n}";
|
|
18
|
+
}, "usePartial": true, "useData": true };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-executor.d.ts","sourceRoot":"","sources":["../../../../src/templatesCompiled/client/core/request-executor.ts"],"names":[],"mappings":";;;;;AAMA,wBAEiB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// This is an automatically generated file for the hbs template.
|
|
4
|
+
// You don't need to change it, run npm run build:hbs to update it.
|
|
5
|
+
/* istanbul ignore file */
|
|
6
|
+
/* tslint: disable */
|
|
7
|
+
/* eslint: disable */
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
exports.default = { "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
|
|
10
|
+
return "export interface RequestConfig {\n method: string;\n url: string;\n headers?: Record<string, string>;\n query?: Record<string, any>;\n body?: unknown;\n}\n\nexport interface RequestExecutor<TOptions = unknown> {\n request<TResponse>(\n config: RequestConfig,\n options?: TOptions\n ): Promise<TResponse>;\n}";
|
|
11
|
+
}, "useData": true };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportService.d.ts","sourceRoot":"","sources":["../../../src/templatesCompiled/client/exportService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAMA,
|
|
1
|
+
{"version":3,"file":"exportService.d.ts","sourceRoot":"","sources":["../../../src/templatesCompiled/client/exportService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAMA,wBAiNoD"}
|
|
@@ -49,10 +49,10 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
|
49
49
|
return undefined;
|
|
50
50
|
};
|
|
51
51
|
return "const "
|
|
52
|
-
+ ((stack1 = container.lambda(container.strict(depth0, "name", { "start": { "line":
|
|
52
|
+
+ ((stack1 = container.lambda(container.strict(depth0, "name", { "start": { "line": 14, "column": 9 }, "end": { "line": 14, "column": 13 } }), depth0)) != null ? stack1 : "")
|
|
53
53
|
+ " = ("
|
|
54
54
|
+ ((stack1 = container.invokePartial(lookupProperty(partials, "parameters"), depth0, { "name": "parameters", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
55
|
-
+ "):
|
|
55
|
+
+ "): RequestConfig => ({\n "
|
|
56
56
|
+ ((stack1 = container.invokePartial(lookupProperty(partials, "serviceOption"), depth0, { "name": "serviceOption", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
57
57
|
+ "});\n\n";
|
|
58
58
|
}, "9": function (container, depth0, helpers, partials, data) {
|
|
@@ -63,16 +63,16 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
|
63
63
|
return undefined;
|
|
64
64
|
};
|
|
65
65
|
return " "
|
|
66
|
-
+ ((stack1 = container.lambda(container.strict(depth0, "name", { "start": { "line":
|
|
66
|
+
+ ((stack1 = container.lambda(container.strict(depth0, "name", { "start": { "line": 22, "column": 7 }, "end": { "line": 22, "column": 11 } }), depth0)) != null ? stack1 : "")
|
|
67
67
|
+ ": ("
|
|
68
68
|
+ ((stack1 = container.invokePartial(lookupProperty(partials, "parametersDefinition"), depth0, { "name": "parametersDefinition", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
69
|
-
+ ") =>
|
|
69
|
+
+ ") => RequestConfig;\n";
|
|
70
70
|
}, "11": function (container, depth0, helpers, partials, data) {
|
|
71
71
|
var stack1, alias1 = container.strict, alias2 = container.lambda;
|
|
72
72
|
return " "
|
|
73
|
-
+ ((stack1 = alias2(alias1(depth0, "name", { "start": { "line":
|
|
73
|
+
+ ((stack1 = alias2(alias1(depth0, "name", { "start": { "line": 28, "column": 7 }, "end": { "line": 28, "column": 11 } }), depth0)) != null ? stack1 : "")
|
|
74
74
|
+ ": "
|
|
75
|
-
+ ((stack1 = alias2(alias1(depth0, "name", { "start": { "line":
|
|
75
|
+
+ ((stack1 = alias2(alias1(depth0, "name", { "start": { "line": 28, "column": 19 }, "end": { "line": 28, "column": 23 } }), depth0)) != null ? stack1 : "")
|
|
76
76
|
+ ",\n";
|
|
77
77
|
}, "13": function (container, depth0, helpers, partials, data, blockParams, depths) {
|
|
78
78
|
var stack1, alias1 = depth0 != null ? depth0 : (container.nullContext || {}), alias2 = container.strict, alias3 = container.lambda, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
@@ -82,33 +82,33 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
|
82
82
|
return undefined;
|
|
83
83
|
};
|
|
84
84
|
return " /**\n"
|
|
85
|
-
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(depth0, "deprecated"), { "name": "if", "hash": {}, "fn": container.program(14, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
86
|
-
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(depth0, "summary"), { "name": "if", "hash": {}, "fn": container.program(16, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
87
|
-
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(depth0, "description"), { "name": "if", "hash": {}, "fn": container.program(18, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
88
|
-
+ ((stack1 = lookupProperty(helpers, "unless").call(alias1, lookupProperty(lookupProperty(data, "root"), "useOptions"), { "name": "unless", "hash": {}, "fn": container.program(20, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
89
|
-
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "results"), { "name": "each", "hash": {}, "fn": container.program(24, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
85
|
+
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(depth0, "deprecated"), { "name": "if", "hash": {}, "fn": container.program(14, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 37, "column": 4 }, "end": { "line": 39, "column": 11 } } })) != null ? stack1 : "")
|
|
86
|
+
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(depth0, "summary"), { "name": "if", "hash": {}, "fn": container.program(16, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 40, "column": 4 }, "end": { "line": 42, "column": 11 } } })) != null ? stack1 : "")
|
|
87
|
+
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(depth0, "description"), { "name": "if", "hash": {}, "fn": container.program(18, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 43, "column": 4 }, "end": { "line": 45, "column": 11 } } })) != null ? stack1 : "")
|
|
88
|
+
+ ((stack1 = lookupProperty(helpers, "unless").call(alias1, lookupProperty(lookupProperty(data, "root"), "useOptions"), { "name": "unless", "hash": {}, "fn": container.program(20, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 46, "column": 4 }, "end": { "line": 52, "column": 15 } } })) != null ? stack1 : "")
|
|
89
|
+
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "results"), { "name": "each", "hash": {}, "fn": container.program(24, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 53, "column": 4 }, "end": { "line": 55, "column": 13 } } })) != null ? stack1 : "")
|
|
90
90
|
+ " * @throws ApiError\n */\n"
|
|
91
|
-
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(lookupProperty(data, "root"), "useCancelableRequest"), { "name": "if", "hash": {}, "fn": container.program(26, data, 0, blockParams, depths), "inverse": container.program(28, data, 0, blockParams, depths), "data": data, "loc": { "start": { "line":
|
|
92
|
-
+ " return
|
|
91
|
+
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(lookupProperty(data, "root"), "useCancelableRequest"), { "name": "if", "hash": {}, "fn": container.program(26, data, 0, blockParams, depths), "inverse": container.program(28, data, 0, blockParams, depths), "data": data, "loc": { "start": { "line": 58, "column": 4 }, "end": { "line": 68, "column": 11 } } })) != null ? stack1 : "")
|
|
92
|
+
+ " return this.executor.request<"
|
|
93
93
|
+ ((stack1 = container.invokePartial(lookupProperty(partials, "result"), depth0, { "name": "result", "hash": { "default": "void" }, "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
94
|
-
+ ">("
|
|
95
|
-
+ ((stack1 = alias3(alias2(depths[1], "originName", { "start": { "line":
|
|
94
|
+
+ ">(\n "
|
|
95
|
+
+ ((stack1 = alias3(alias2(depths[1], "originName", { "start": { "line": 70, "column": 15 }, "end": { "line": 70, "column": 28 } }), depth0)) != null ? stack1 : "")
|
|
96
96
|
+ "Options."
|
|
97
|
-
+ ((stack1 = alias3(alias2(depth0, "name", { "start": { "line":
|
|
97
|
+
+ ((stack1 = alias3(alias2(depth0, "name", { "start": { "line": 70, "column": 42 }, "end": { "line": 70, "column": 46 } }), depth0)) != null ? stack1 : "")
|
|
98
98
|
+ "("
|
|
99
99
|
+ ((stack1 = container.invokePartial(lookupProperty(partials, "parameterValues"), depth0, { "name": "parameterValues", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
100
|
-
+ ")
|
|
100
|
+
+ "),\n options\n );\n }\n";
|
|
101
101
|
}, "14": function (container, depth0, helpers, partials, data) {
|
|
102
102
|
return " * @deprecated\n";
|
|
103
103
|
}, "16": function (container, depth0, helpers, partials, data) {
|
|
104
104
|
var stack1;
|
|
105
105
|
return " * "
|
|
106
|
-
+ ((stack1 = container.lambda(container.strict(depth0, "summary", { "start": { "line":
|
|
106
|
+
+ ((stack1 = container.lambda(container.strict(depth0, "summary", { "start": { "line": 41, "column": 10 }, "end": { "line": 41, "column": 17 } }), depth0)) != null ? stack1 : "")
|
|
107
107
|
+ "\n";
|
|
108
108
|
}, "18": function (container, depth0, helpers, partials, data) {
|
|
109
109
|
var stack1;
|
|
110
110
|
return " * "
|
|
111
|
-
+ ((stack1 = container.lambda(container.strict(depth0, "description", { "start": { "line":
|
|
111
|
+
+ ((stack1 = container.lambda(container.strict(depth0, "description", { "start": { "line": 44, "column": 10 }, "end": { "line": 44, "column": 21 } }), depth0)) != null ? stack1 : "")
|
|
112
112
|
+ "\n";
|
|
113
113
|
}, "20": function (container, depth0, helpers, partials, data) {
|
|
114
114
|
var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
@@ -117,7 +117,7 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
|
117
117
|
}
|
|
118
118
|
return undefined;
|
|
119
119
|
};
|
|
120
|
-
return ((stack1 = lookupProperty(helpers, "if").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "parameters"), { "name": "if", "hash": {}, "fn": container.program(21, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
120
|
+
return ((stack1 = lookupProperty(helpers, "if").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "parameters"), { "name": "if", "hash": {}, "fn": container.program(21, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 47, "column": 4 }, "end": { "line": 51, "column": 11 } } })) != null ? stack1 : "");
|
|
121
121
|
}, "21": function (container, depth0, helpers, partials, data) {
|
|
122
122
|
var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
123
123
|
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
|
|
@@ -125,20 +125,20 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
|
125
125
|
}
|
|
126
126
|
return undefined;
|
|
127
127
|
};
|
|
128
|
-
return ((stack1 = lookupProperty(helpers, "each").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "parameters"), { "name": "each", "hash": {}, "fn": container.program(22, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
128
|
+
return ((stack1 = lookupProperty(helpers, "each").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "parameters"), { "name": "each", "hash": {}, "fn": container.program(22, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 48, "column": 4 }, "end": { "line": 50, "column": 13 } } })) != null ? stack1 : "");
|
|
129
129
|
}, "22": function (container, depth0, helpers, partials, data) {
|
|
130
130
|
var stack1, alias1 = container.strict, alias2 = container.lambda;
|
|
131
131
|
return " * @param "
|
|
132
|
-
+ ((stack1 = alias2(alias1(depth0, "name", { "start": { "line":
|
|
132
|
+
+ ((stack1 = alias2(alias1(depth0, "name", { "start": { "line": 49, "column": 17 }, "end": { "line": 49, "column": 21 } }), depth0)) != null ? stack1 : "")
|
|
133
133
|
+ " "
|
|
134
|
-
+ ((stack1 = alias2(alias1(depth0, "description", { "start": { "line":
|
|
134
|
+
+ ((stack1 = alias2(alias1(depth0, "description", { "start": { "line": 49, "column": 28 }, "end": { "line": 49, "column": 39 } }), depth0)) != null ? stack1 : "")
|
|
135
135
|
+ "\n";
|
|
136
136
|
}, "24": function (container, depth0, helpers, partials, data) {
|
|
137
137
|
var stack1, alias1 = container.strict, alias2 = container.lambda;
|
|
138
138
|
return " * @returns "
|
|
139
|
-
+ ((stack1 = alias2(alias1(depth0, "type", { "start": { "line":
|
|
139
|
+
+ ((stack1 = alias2(alias1(depth0, "type", { "start": { "line": 54, "column": 19 }, "end": { "line": 54, "column": 23 } }), depth0)) != null ? stack1 : "")
|
|
140
140
|
+ " "
|
|
141
|
-
+ ((stack1 = alias2(alias1(depth0, "description", { "start": { "line":
|
|
141
|
+
+ ((stack1 = alias2(alias1(depth0, "description", { "start": { "line": 54, "column": 30 }, "end": { "line": 54, "column": 41 } }), depth0)) != null ? stack1 : "")
|
|
142
142
|
+ "\n";
|
|
143
143
|
}, "26": function (container, depth0, helpers, partials, data) {
|
|
144
144
|
var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
@@ -147,11 +147,11 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
|
147
147
|
}
|
|
148
148
|
return undefined;
|
|
149
149
|
};
|
|
150
|
-
return " public
|
|
151
|
-
+ ((stack1 = container.lambda(container.strict(depth0, "name", { "start": { "line":
|
|
152
|
-
+ "("
|
|
150
|
+
return " public "
|
|
151
|
+
+ ((stack1 = container.lambda(container.strict(depth0, "name", { "start": { "line": 59, "column": 14 }, "end": { "line": 59, "column": 18 } }), depth0)) != null ? stack1 : "")
|
|
152
|
+
+ "(\n "
|
|
153
153
|
+ ((stack1 = container.invokePartial(lookupProperty(partials, "parameters"), depth0, { "name": "parameters", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
154
|
-
+ "): CancelablePromise<"
|
|
154
|
+
+ " options?: TOptions,\n ): CancelablePromise<"
|
|
155
155
|
+ ((stack1 = container.invokePartial(lookupProperty(partials, "result"), depth0, { "name": "result", "hash": { "default": "void" }, "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
156
156
|
+ "> {\n";
|
|
157
157
|
}, "28": function (container, depth0, helpers, partials, data) {
|
|
@@ -161,11 +161,11 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
|
161
161
|
}
|
|
162
162
|
return undefined;
|
|
163
163
|
};
|
|
164
|
-
return " public
|
|
165
|
-
+ ((stack1 = container.lambda(container.strict(depth0, "name", { "start": { "line":
|
|
166
|
-
+ "("
|
|
164
|
+
return " public "
|
|
165
|
+
+ ((stack1 = container.lambda(container.strict(depth0, "name", { "start": { "line": 64, "column": 14 }, "end": { "line": 64, "column": 18 } }), depth0)) != null ? stack1 : "")
|
|
166
|
+
+ "(\n "
|
|
167
167
|
+ ((stack1 = container.invokePartial(lookupProperty(partials, "parameters"), depth0, { "name": "parameters", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
168
|
-
+ "): Promise<"
|
|
168
|
+
+ " options?: TOptions,\n ): Promise<"
|
|
169
169
|
+ ((stack1 = container.invokePartial(lookupProperty(partials, "result"), depth0, { "name": "result", "hash": { "default": "void" }, "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
170
170
|
+ "> {\n";
|
|
171
171
|
}, "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data, blockParams, depths) {
|
|
@@ -179,27 +179,23 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
|
179
179
|
+ "\n"
|
|
180
180
|
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(depth0, "imports"), { "name": "if", "hash": {}, "fn": container.program(1, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 7, "column": 7 } } })) != null ? stack1 : "")
|
|
181
181
|
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(lookupProperty(data, "root"), "useCancelableRequest"), { "name": "if", "hash": {}, "fn": container.program(5, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 10, "column": 7 } } })) != null ? stack1 : "")
|
|
182
|
-
+ "import {
|
|
183
|
-
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "request", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 11, "column":
|
|
184
|
-
+ "';\nimport type { ApiRequestOptions } from '"
|
|
185
|
-
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "ApiRequestOptions", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 12, "column": 40 }, "end": { "line": 12, "column": 91 } } })) != null ? stack1 : "")
|
|
186
|
-
+ "';\nimport { OpenAPI } from '"
|
|
187
|
-
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "OpenAPI", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 13, "column": 25 }, "end": { "line": 13, "column": 66 } } })) != null ? stack1 : "")
|
|
182
|
+
+ "import type { RequestExecutor, RequestConfig } from '"
|
|
183
|
+
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "request-executor", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 11, "column": 53 }, "end": { "line": 11, "column": 103 } } })) != null ? stack1 : "")
|
|
188
184
|
+ "';\n\n"
|
|
189
|
-
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "operations"), { "name": "each", "hash": {}, "fn": container.program(7, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
185
|
+
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "operations"), { "name": "each", "hash": {}, "fn": container.program(7, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 18, "column": 9 } } })) != null ? stack1 : "")
|
|
190
186
|
+ "\nexport type T"
|
|
191
|
-
+ ((stack1 = alias3(alias2(depth0, "originName", { "start": { "line":
|
|
187
|
+
+ ((stack1 = alias3(alias2(depth0, "originName", { "start": { "line": 20, "column": 16 }, "end": { "line": 20, "column": 26 } }), depth0)) != null ? stack1 : "")
|
|
192
188
|
+ "Options = {\n"
|
|
193
|
-
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "operations"), { "name": "each", "hash": {}, "fn": container.program(9, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
194
|
-
+ "}
|
|
195
|
-
+ ((stack1 = alias3(alias2(depth0, "originName", { "start": { "line":
|
|
189
|
+
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "operations"), { "name": "each", "hash": {}, "fn": container.program(9, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 21, "column": 0 }, "end": { "line": 23, "column": 9 } } })) != null ? stack1 : "")
|
|
190
|
+
+ "};\n\nexport const "
|
|
191
|
+
+ ((stack1 = alias3(alias2(depth0, "originName", { "start": { "line": 26, "column": 16 }, "end": { "line": 26, "column": 26 } }), depth0)) != null ? stack1 : "")
|
|
196
192
|
+ "Options: T"
|
|
197
|
-
+ ((stack1 = alias3(alias2(depth0, "originName", { "start": { "line":
|
|
193
|
+
+ ((stack1 = alias3(alias2(depth0, "originName", { "start": { "line": 26, "column": 42 }, "end": { "line": 26, "column": 52 } }), depth0)) != null ? stack1 : "")
|
|
198
194
|
+ "Options = {\n"
|
|
199
|
-
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "operations"), { "name": "each", "hash": {}, "fn": container.program(11, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
200
|
-
+ "}
|
|
201
|
-
+ ((stack1 = alias3(alias2(depth0, "name", { "start": { "line":
|
|
202
|
-
+ " {\n\n"
|
|
203
|
-
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "operations"), { "name": "each", "hash": {}, "fn": container.program(13, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
195
|
+
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "operations"), { "name": "each", "hash": {}, "fn": container.program(11, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 27, "column": 0 }, "end": { "line": 29, "column": 9 } } })) != null ? stack1 : "")
|
|
196
|
+
+ "};\n\nexport class "
|
|
197
|
+
+ ((stack1 = alias3(alias2(depth0, "name", { "start": { "line": 32, "column": 16 }, "end": { "line": 32, "column": 20 } }), depth0)) != null ? stack1 : "")
|
|
198
|
+
+ "<TOptions = unknown> {\n constructor(private readonly executor: RequestExecutor<TOptions>) {}\n\n"
|
|
199
|
+
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "operations"), { "name": "each", "hash": {}, "fn": container.program(13, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 35, "column": 4 }, "end": { "line": 74, "column": 13 } } })) != null ? stack1 : "")
|
|
204
200
|
+ "}\n";
|
|
205
201
|
}, "usePartial": true, "useData": true, "useDepths": true };
|
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.1",
|
|
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",
|