From bc8eae838c157eba6fecc6cf86f18a720d0cb486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mads=20M=C3=A6tzke=20Tandrup?= Date: Fri, 24 Jul 2015 10:14:42 +0200 Subject: [PATCH] Beautify typescript angular output --- .../resources/TypeScript-Angular/api.mustache | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache index bd5eaaef87a..427d847663b 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache @@ -6,11 +6,11 @@ module {{package}} { 'use strict'; - {{#description}} +{{#description}} /** * {{&description}} */ - {{/description}} +{{/description}} export class {{classname}} { private basePath = '{{contextPath}}'; @@ -21,24 +21,37 @@ module {{package}} { this.basePath = basePath; } } - {{#operation}} +{{#operation}} + public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : ng.IHttpPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> { var path = this.basePath + '{{path}}'; - {{#pathParams}} + +{{#pathParams}} path = path.replace('{' + '{{paramName}}' + '}', String({{paramName}})); - {{/pathParams}} + +{{/pathParams}} var queryParameters: any = {}; var headerParams: any = {}; - {{#allParams}}{{#required}} + +{{#allParams}} +{{#required}} // verify required parameter '{{paramName}}' is set if (!{{paramName}}) { throw new Error('Missing required parameter {{paramName}} when calling {{nickname}}'); } - {{/required}}{{/allParams}} - {{#queryParams}}if ({{paramName}} !== undefined) { + +{{/required}} +{{/allParams}} +{{#queryParams}} + if ({{paramName}} !== undefined) { queryParameters['{{paramName}}'] = {{paramName}}; - }{{/queryParams}} - {{#headerParams}}headerParams['{{paramName}}'] = {{paramName}};{{/headerParams}} + } + +{{/queryParams}} +{{#headerParams}} + headerParams['{{paramName}}'] = {{paramName}}; + +{{/headerParams}} var httpRequestParams: any = { method: '{{httpMethod}}', url: path, @@ -59,7 +72,7 @@ module {{package}} { return this.$http(httpRequestParams); } - {{/operation}} +{{/operation}} } } {{/operations}}