Skip to content

Commit 06a5a45

Browse files
author
A.K Sahin
committed
feat(exportService): infer return type instead from possible custom request file
1 parent c12f703 commit 06a5a45

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

bin/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ const params = program
2828
const OpenAPI = require(path.resolve(__dirname, '../dist/index.js'));
2929

3030
const genereteParams = {
31-
input: program.input,
32-
output: program.output,
33-
httpClient: program.client,
34-
useOptions: program.useOptions,
35-
useUnionTypes: program.useUnionTypes,
36-
exportCore: JSON.parse(program.exportCore) === true,
37-
exportServices: JSON.parse(program.exportServices) === true,
38-
exportModels: JSON.parse(program.exportModels) === true,
39-
exportSchemas: JSON.parse(program.exportSchemas) === true,
31+
input: params.input,
32+
output: params.output,
33+
httpClient: params.client,
34+
useOptions: params.useOptions,
35+
useUnionTypes: params.useUnionTypes,
36+
exportCore: JSON.parse(params.exportCore) === true,
37+
exportServices: JSON.parse(params.exportServices) === true,
38+
exportModels: JSON.parse(params.exportModels) === true,
39+
exportSchemas: JSON.parse(params.exportSchemas) === true,
4040
postfix: params.postfix,
4141
request: params.request,
4242
};
4343

44-
if (program.serviceOptions) {
45-
genereteParams.serviceOptions = require(path.resolve(__dirname, '../../', program.serviceOptions));
44+
if (params.serviceOptions) {
45+
genereteParams.serviceOptions = require(resolve(process.cwd(), params.serviceOptions));
4646
}
4747

4848
if (OpenAPI) {

src/templates/exportService.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export class {{{name}}}{{{@root.postfix}}} {
4545
{{/each}}
4646
* @throws ApiError
4747
*/
48-
public{{#if @root.staticMethods}} static{{/if}} {{{name}}}({{>parameters}}): CancelablePromise<{{>result}}> {
49-
return __request({
48+
public{{#if @root.staticMethods}} static{{/if}} {{{name}}}({{>parameters}}) {
49+
return __request<{{>result}}>({
5050
method: '{{{method}}}',
5151
path: `{{{path}}}`,
5252
{{#if parametersCookie}}

src/utils/writeClient.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('writeClient', () => {
3232
},
3333
};
3434

35-
await writeClient(client, templates, './dist', HttpClient.FETCH, false, false, true, true, true, true, '');
35+
await writeClient(client, templates, './dist', HttpClient.FETCH, false, false, true, true, true, true, '', {});
3636

3737
expect(rmdir).toBeCalled();
3838
expect(mkdir).toBeCalled();

src/utils/writeClientServices.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('writeClientServices', () => {
3333
},
3434
};
3535

36-
await writeClientServices(services, templates, '/', HttpClient.FETCH, false, false, 'Service');
36+
await writeClientServices(services, templates, '/', HttpClient.FETCH, false, false, 'Service', {});
3737

3838
expect(writeFile).toBeCalledWith('/UserService.ts', 'service');
3939
});

src/utils/writeClientServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { resolve } from 'path';
2-
import { ServiceOptions } from '..';
32

3+
import { ServiceOptions } from '..';
44
import type { Service } from '../client/interfaces/Service';
55
import { HttpClient } from '../HttpClient';
66
import { writeFile } from './fileSystem';

0 commit comments

Comments
 (0)