diff --git a/src/templates/client.hbs b/src/templates/client.hbs index 601f27d8f..69be6ea2f 100644 --- a/src/templates/client.hbs +++ b/src/templates/client.hbs @@ -17,6 +17,9 @@ import { {{{httpRequest}}} } from './core/{{{httpRequest}}}'; {{#if services}} {{#each services}} import { {{{name}}}{{{@root.postfix}}} } from './services/{{{name}}}{{{@root.postfix}}}'; +{{#unless @last}} + +{{/unless}} {{/each}} {{/if}} diff --git a/src/templates/core/BaseHttpRequest.hbs b/src/templates/core/BaseHttpRequest.hbs index 43ff79cbb..4fdf28a80 100644 --- a/src/templates/core/BaseHttpRequest.hbs +++ b/src/templates/core/BaseHttpRequest.hbs @@ -13,7 +13,6 @@ import type { OpenAPIConfig } from './OpenAPI'; {{/equals}} export abstract class BaseHttpRequest { - {{#equals @root.httpClient 'angular'}} constructor( public readonly config: OpenAPIConfig, diff --git a/src/templates/core/CancelablePromise.hbs b/src/templates/core/CancelablePromise.hbs index b708b4edc..eb839466c 100644 --- a/src/templates/core/CancelablePromise.hbs +++ b/src/templates/core/CancelablePromise.hbs @@ -1,7 +1,6 @@ {{>header}} export class CancelError extends Error { - constructor(message: string) { super(message); this.name = 'CancelError'; diff --git a/src/templates/core/HttpRequest.hbs b/src/templates/core/HttpRequest.hbs index e1620a3c0..fdefe7742 100644 --- a/src/templates/core/HttpRequest.hbs +++ b/src/templates/core/HttpRequest.hbs @@ -22,7 +22,6 @@ import { request as __request } from './request'; @Injectable() {{/equals}} export class {{httpRequest}} extends BaseHttpRequest { - {{#equals @root.httpClient 'angular'}} constructor( @Inject(OpenAPI) diff --git a/src/templates/exportService.hbs b/src/templates/exportService.hbs index d6bccbbeb..f74c54a65 100644 --- a/src/templates/exportService.hbs +++ b/src/templates/exportService.hbs @@ -38,15 +38,14 @@ import { request as __request } from '../core/request'; {{/equals}} export class {{{name}}}{{{@root.postfix}}} { {{#if @root.exportClient}} - constructor(public readonly httpRequest: BaseHttpRequest) {} + {{else}} {{#equals @root.httpClient 'angular'}} - constructor(public readonly http: HttpClient) {} + {{/equals}} {{/if}} - {{#each operations}} /** {{#if deprecated}} @@ -56,7 +55,9 @@ export class {{{name}}}{{{@root.postfix}}} { * {{{escapeComment summary}}} {{/if}} {{#if description}} + {{#notEquals summary description}} * {{{escapeComment description}}} + {{/notEquals}} {{/if}} {{#unless @root.useOptions}} {{#if parameters}} @@ -113,7 +114,11 @@ export class {{{name}}}{{{@root.postfix}}} { {{#if parametersQuery}} query: { {{#each parametersQuery}} + {{#equals prop name}} + {{{name}}}, + {{else}} '{{{prop}}}': {{{name}}}, + {{/equals}} {{/each}} }, {{/if}} @@ -147,6 +152,8 @@ export class {{{name}}}{{{@root.postfix}}} { {{/if}} }); } + {{#unless @last}} + {{/unless}} {{/each}} } diff --git a/src/templates/partials/exportComposition.hbs b/src/templates/partials/exportComposition.hbs index 15bf6f65c..c66c6acde 100644 --- a/src/templates/partials/exportComposition.hbs +++ b/src/templates/partials/exportComposition.hbs @@ -13,7 +13,6 @@ export type {{{name}}} = {{>type parent=name}}; {{#unless @root.useUnionTypes}} export namespace {{{name}}} { - {{#each enums}} {{#ifdef description deprecated}} /** @@ -30,9 +29,10 @@ export namespace {{{name}}} { {{{name}}} = {{{value}}}, {{/each}} } + {{#unless @last}} + {{/unless}} {{/each}} - } {{/unless}} {{/if}} diff --git a/src/templates/partials/exportInterface.hbs b/src/templates/partials/exportInterface.hbs index b61e26441..708b0ab18 100644 --- a/src/templates/partials/exportInterface.hbs +++ b/src/templates/partials/exportInterface.hbs @@ -27,7 +27,6 @@ export type {{{name}}} = { {{#unless @root.useUnionTypes}} export namespace {{{name}}} { - {{#each enums}} {{#if description}} /** @@ -39,9 +38,10 @@ export namespace {{{name}}} { {{{name}}} = {{{value}}}, {{/each}} } + {{#unless @last}} + {{/unless}} {{/each}} - } {{/unless}} {{/if}} diff --git a/src/utils/formatIndentation.ts b/src/utils/formatIndentation.ts index 63e1ca912..caba7a5d8 100644 --- a/src/utils/formatIndentation.ts +++ b/src/utils/formatIndentation.ts @@ -3,8 +3,7 @@ import { EOL } from 'os'; import { Indent } from '../Indent'; export const formatIndentation = (s: string, indent: Indent): string => { - let lines = s.split(EOL); - lines = lines.map(line => { + const lines = s.split(EOL).map(line => { switch (indent) { case Indent.SPACE_4: return line.replace(/\t/g, ' '); @@ -16,5 +15,9 @@ export const formatIndentation = (s: string, indent: Indent): string => { }); // Make sure we have a blank line at the end const content = lines.join(EOL); - return `${content}${EOL}`; + if (s.at(-1) === EOL) { + return `${content}`; + } else { + return `${content}${EOL}`; + } };