Skip to content

Commit

Permalink
Merge pull request #37 from nicolas-chaulet/fix/client-name-types
Browse files Browse the repository at this point in the history
fix(types): do not insert generics into custom client
  • Loading branch information
mrlubos authored Mar 5, 2024
2 parents 18275ad + c0d4fcf commit 478d794
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
12 changes: 12 additions & 0 deletions src/templates/partials/destructureData.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
{{~#if @root.exportClient~}}
{{#if @root.useOptions~}}
{{#if parameters}}
const {
{{#each parameters}}
{{{name}}}{{#if default}} = {{{default}}}{{/if}},
{{/each}}
} = data;
{{/if}}
{{/if}}
{{~else~}}
{{#if @root.useOptions~}}
const {
{{#each parameters}}
Expand All @@ -6,3 +17,4 @@ const {
...overrides
} = data;
{{/if}}
{{~/if~}}
4 changes: 4 additions & 0 deletions src/templates/partials/operationParameters.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{{#if @root.useOptions~}}
{{~#if @root.exportClient~}}
{{#if parameters}}data: {{{nameOperationDataType name}}}{{#ifOperationDataOptional parameters}} = {}{{/ifOperationDataOptional}}{{/if}}
{{~else~}}
data: {{#if parameters}}{{{nameOperationDataType name}}} & {{/if}}TConfig<T>{{#ifOperationDataOptional parameters}} = {}{{/ifOperationDataOptional}}
{{~/if~}}
{{~else}}
{{#if parameters}}

Expand Down
8 changes: 4 additions & 4 deletions src/templates/partials/operationResult.hbs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{~#if @root.useOptions~}}
TApiResponse<T, {{/if~}}
{{~#if @root.useOptions~}}{{~#unless @root.exportClient~}}
TApiResponse<T, {{/unless}}{{/if~}}
{{~#if results~}}
{{#each results}}{{>type}}{{#unless @last}} | {{/unless}}{{/each}}
{{~else~}}
void
{{~/if~}}
{{~#if @root.useOptions~}}
{{~#if @root.useOptions~}}{{~#unless @root.exportClient~}}
>
{{~/if~}}
{{~/unless~}}{{~/if~}}
2 changes: 2 additions & 0 deletions src/templates/partials/operationTypes.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{#if @root.useOptions~}}
{{~#unless @root.exportClient~}}
<T extends TResult>
{{~/unless~}}
{{~/if}}
9 changes: 5 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ const generate = async (input, output) => {
exportModels: true,
exportSchemas: true,
exportServices: true,
httpClient: OpenAPI.HttpClient.FETCH,
// indent: OpenAPI.Indent.SPACE_2,
httpClient: 'fetch',
// indent: '2',
input,
output,
// postfix: 'Service',
// postfixServices: 'Service',
postfixModels: '',
// request: './test/custom/request.ts',
useDateType: false,
useOptions: true,
useUnionTypes: false,
useUnionTypes: true,
});
};

Expand Down

0 comments on commit 478d794

Please sign in to comment.