diff --git a/src/templates/partials/destructureData.hbs b/src/templates/partials/destructureData.hbs index 65fde007f..c7ff08c32 100644 --- a/src/templates/partials/destructureData.hbs +++ b/src/templates/partials/destructureData.hbs @@ -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}} @@ -6,3 +17,4 @@ const { ...overrides } = data; {{/if}} +{{~/if~}} diff --git a/src/templates/partials/operationParameters.hbs b/src/templates/partials/operationParameters.hbs index 29754ee43..8da5566b2 100644 --- a/src/templates/partials/operationParameters.hbs +++ b/src/templates/partials/operationParameters.hbs @@ -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{{#ifOperationDataOptional parameters}} = {}{{/ifOperationDataOptional}} +{{~/if~}} {{~else}} {{#if parameters}} diff --git a/src/templates/partials/operationResult.hbs b/src/templates/partials/operationResult.hbs index 876eacdf1..16e25bbda 100644 --- a/src/templates/partials/operationResult.hbs +++ b/src/templates/partials/operationResult.hbs @@ -1,10 +1,10 @@ -{{~#if @root.useOptions~}} -TApiResponsetype}}{{#unless @last}} | {{/unless}}{{/each}} {{~else~}} void {{~/if~}} -{{~#if @root.useOptions~}} +{{~#if @root.useOptions~}}{{~#unless @root.exportClient~}} > -{{~/if~}} \ No newline at end of file +{{~/unless~}}{{~/if~}} \ No newline at end of file diff --git a/src/templates/partials/operationTypes.hbs b/src/templates/partials/operationTypes.hbs index 765826190..b737c1f25 100644 --- a/src/templates/partials/operationTypes.hbs +++ b/src/templates/partials/operationTypes.hbs @@ -1,3 +1,5 @@ {{#if @root.useOptions~}} +{{~#unless @root.exportClient~}} +{{~/unless~}} {{~/if}} diff --git a/test/index.js b/test/index.js index 4d0ad4ab0..5b24749a5 100644 --- a/test/index.js +++ b/test/index.js @@ -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, }); };