From 4e7d893a8e637d1072791a8422d4465412fce657 Mon Sep 17 00:00:00 2001 From: aersamkull Date: Tue, 13 Oct 2015 12:01:34 +0200 Subject: [PATCH 1/2] Updates to TypeScript Templates --- .../resources/TypeScript-Angular/api.mustache | 14 +++++++------- .../resources/TypeScript-Angular/model.mustache | 6 +++--- .../main/resources/TypeScript-node/api.mustache | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 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 233ead8bee4..2045dd35382 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache @@ -3,7 +3,7 @@ /* tslint:disable:no-unused-variable member-ordering */ {{#operations}} -module {{package}} { +namespace {{package}} { 'use strict'; {{#description}} @@ -24,16 +24,16 @@ module {{package}} { {{#operation}} public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : ng.IHttpPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> { - var path = this.basePath + '{{path}}'; + let path = this.basePath + '{{path}}'; {{#pathParams}} path = path.replace('{' + '{{baseName}}' + '}', String({{paramName}})); {{/pathParams}} - var queryParameters: any = {}; - var headerParams: any = {}; + let queryParameters: any = {}; + let headerParams: any = {}; {{#hasFormParams}} - var formParams: any = {}; + let formParams: any = {}; {{/hasFormParams}} {{#allParams}} @@ -63,7 +63,7 @@ module {{package}} { formParams['{{baseName}}'] = {{paramName}}; {{/formParams}} - var httpRequestParams: any = { + let httpRequestParams: any = { method: '{{httpMethod}}', url: path, json: {{#hasFormParams}}false{{/hasFormParams}}{{^hasFormParams}}true{{/hasFormParams}}, @@ -76,7 +76,7 @@ module {{package}} { }; if (extraHttpRequestParams) { - for (var k in extraHttpRequestParams) { + for (let k in extraHttpRequestParams) { if (extraHttpRequestParams.hasOwnProperty(k)) { httpRequestParams[k] = extraHttpRequestParams[k]; } diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Angular/model.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/model.mustache index b425d14d5e4..5b57ed4dc94 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Angular/model.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/model.mustache @@ -1,6 +1,6 @@ /// -module {{package}} { +namespace {{package}} { 'use strict'; {{#models}} @@ -10,7 +10,7 @@ module {{package}} { * {{{description}}} */ {{/description}} - export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ + export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ {{#vars}} {{#description}} @@ -23,7 +23,7 @@ module {{package}} { } {{#hasEnums}} - export module {{classname}} { + export namespace {{classname}} { {{#vars}} {{#isEnum}} diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-node/api.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-node/api.mustache index 6528a5d3a22..4d03ae0f424 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-node/api.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-node/api.mustache @@ -27,7 +27,7 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ } {{#hasEnums}} -export module {{classname}} { +export namespace {{classname}} { {{#vars}} {{#isEnum}} export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}} @@ -157,15 +157,15 @@ export class {{classname}} { {{#operation}} public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : Promise<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }> { - var path = this.url + this.basePath + '{{path}}'; + let path = this.url + this.basePath + '{{path}}'; {{#pathParams}} path = path.replace('{' + '{{baseName}}' + '}', String({{paramName}})); {{/pathParams}} - var queryParameters: any = {}; - var headerParams: any = {}; - var formParams: any = {}; + let queryParameters: any = {}; + let headerParams: any = {}; + let formParams: any = {}; {{#allParams}}{{#required}} // verify required parameter '{{paramName}}' is set @@ -183,7 +183,7 @@ export class {{classname}} { headerParams['{{baseName}}'] = {{paramName}}; {{/headerParams}} - var useFormData = false; + let useFormData = false; {{#formParams}} if ({{paramName}} !== undefined) { @@ -194,9 +194,9 @@ export class {{classname}} { {{/isFile}} {{/formParams}} - var deferred = promise.defer<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }>(); + let deferred = promise.defer<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }>(); - var requestOptions: request.Options = { + let requestOptions: request.Options = { method: '{{httpMethod}}', qs: queryParameters, headers: headerParams, From 988de07c1798890d0468ecfdcfe32db5a246b119 Mon Sep 17 00:00:00 2001 From: aersamkull Date: Tue, 13 Oct 2015 13:32:01 +0200 Subject: [PATCH 2/2] Fixes noImplicitAny Error --- .../src/main/resources/TypeScript-Angular/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2045dd35382..9681634a765 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/api.mustache @@ -16,7 +16,7 @@ namespace {{package}} { static $inject: string[] = ['$http', '$httpParamSerializer']; - constructor(private $http: ng.IHttpService, basePath?: string, private $httpParamSerializer?: (any) => any) { + constructor(private $http: ng.IHttpService, basePath?: string, private $httpParamSerializer?: (d: any) => any) { if (basePath) { this.basePath = basePath; }