Skip to content

Commit 478d794

Browse files
authored
Merge pull request #37 from nicolas-chaulet/fix/client-name-types
fix(types): do not insert generics into custom client
2 parents 18275ad + c0d4fcf commit 478d794

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

src/templates/partials/destructureData.hbs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
{{~#if @root.exportClient~}}
2+
{{#if @root.useOptions~}}
3+
{{#if parameters}}
4+
const {
5+
{{#each parameters}}
6+
{{{name}}}{{#if default}} = {{{default}}}{{/if}},
7+
{{/each}}
8+
} = data;
9+
{{/if}}
10+
{{/if}}
11+
{{~else~}}
112
{{#if @root.useOptions~}}
213
const {
314
{{#each parameters}}
@@ -6,3 +17,4 @@ const {
617
...overrides
718
} = data;
819
{{/if}}
20+
{{~/if~}}

src/templates/partials/operationParameters.hbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{{#if @root.useOptions~}}
2+
{{~#if @root.exportClient~}}
3+
{{#if parameters}}data: {{{nameOperationDataType name}}}{{#ifOperationDataOptional parameters}} = {}{{/ifOperationDataOptional}}{{/if}}
4+
{{~else~}}
25
data: {{#if parameters}}{{{nameOperationDataType name}}} & {{/if}}TConfig<T>{{#ifOperationDataOptional parameters}} = {}{{/ifOperationDataOptional}}
6+
{{~/if~}}
37
{{~else}}
48
{{#if parameters}}
59

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
{{~#if @root.useOptions~}}
2-
TApiResponse<T, {{/if~}}
1+
{{~#if @root.useOptions~}}{{~#unless @root.exportClient~}}
2+
TApiResponse<T, {{/unless}}{{/if~}}
33
{{~#if results~}}
44
{{#each results}}{{>type}}{{#unless @last}} | {{/unless}}{{/each}}
55
{{~else~}}
66
void
77
{{~/if~}}
8-
{{~#if @root.useOptions~}}
8+
{{~#if @root.useOptions~}}{{~#unless @root.exportClient~}}
99
>
10-
{{~/if~}}
10+
{{~/unless~}}{{~/if~}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{{#if @root.useOptions~}}
2+
{{~#unless @root.exportClient~}}
23
<T extends TResult>
4+
{{~/unless~}}
35
{{~/if}}

test/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ const generate = async (input, output) => {
1111
exportModels: true,
1212
exportSchemas: true,
1313
exportServices: true,
14-
httpClient: OpenAPI.HttpClient.FETCH,
15-
// indent: OpenAPI.Indent.SPACE_2,
14+
httpClient: 'fetch',
15+
// indent: '2',
1616
input,
1717
output,
18-
// postfix: 'Service',
18+
// postfixServices: 'Service',
19+
postfixModels: '',
1920
// request: './test/custom/request.ts',
2021
useDateType: false,
2122
useOptions: true,
22-
useUnionTypes: false,
23+
useUnionTypes: true,
2324
});
2425
};
2526

0 commit comments

Comments
 (0)