Merge pull request #1385 from aersamkull/master

Updates to TypeScript Templates 2
This commit is contained in:
wing328 2015-10-15 09:46:46 +08:00
commit 265b4b5945
3 changed files with 19 additions and 19 deletions

View File

@ -3,7 +3,7 @@
/* tslint:disable:no-unused-variable member-ordering */ /* tslint:disable:no-unused-variable member-ordering */
{{#operations}} {{#operations}}
module {{package}} { namespace {{package}} {
'use strict'; 'use strict';
{{#description}} {{#description}}
@ -16,7 +16,7 @@ module {{package}} {
static $inject: string[] = ['$http', '$httpParamSerializer']; 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) { if (basePath) {
this.basePath = basePath; this.basePath = basePath;
} }
@ -24,16 +24,16 @@ module {{package}} {
{{#operation}} {{#operation}}
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : ng.IHttpPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> { 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}} {{#pathParams}}
path = path.replace('{' + '{{baseName}}' + '}', String({{paramName}})); path = path.replace('{' + '{{baseName}}' + '}', String({{paramName}}));
{{/pathParams}} {{/pathParams}}
var queryParameters: any = {}; let queryParameters: any = {};
var headerParams: any = {}; let headerParams: any = {};
{{#hasFormParams}} {{#hasFormParams}}
var formParams: any = {}; let formParams: any = {};
{{/hasFormParams}} {{/hasFormParams}}
{{#allParams}} {{#allParams}}
@ -63,7 +63,7 @@ module {{package}} {
formParams['{{baseName}}'] = {{paramName}}; formParams['{{baseName}}'] = {{paramName}};
{{/formParams}} {{/formParams}}
var httpRequestParams: any = { let httpRequestParams: any = {
method: '{{httpMethod}}', method: '{{httpMethod}}',
url: path, url: path,
json: {{#hasFormParams}}false{{/hasFormParams}}{{^hasFormParams}}true{{/hasFormParams}}, json: {{#hasFormParams}}false{{/hasFormParams}}{{^hasFormParams}}true{{/hasFormParams}},
@ -76,7 +76,7 @@ module {{package}} {
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
for (var k in extraHttpRequestParams) { for (let k in extraHttpRequestParams) {
if (extraHttpRequestParams.hasOwnProperty(k)) { if (extraHttpRequestParams.hasOwnProperty(k)) {
httpRequestParams[k] = extraHttpRequestParams[k]; httpRequestParams[k] = extraHttpRequestParams[k];
} }

View File

@ -1,6 +1,6 @@
/// <reference path="api.d.ts" /> /// <reference path="api.d.ts" />
module {{package}} { namespace {{package}} {
'use strict'; 'use strict';
{{#models}} {{#models}}
@ -10,7 +10,7 @@ module {{package}} {
* {{{description}}} * {{{description}}}
*/ */
{{/description}} {{/description}}
export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
{{#vars}} {{#vars}}
{{#description}} {{#description}}
@ -23,7 +23,7 @@ module {{package}} {
} }
{{#hasEnums}} {{#hasEnums}}
export module {{classname}} { export namespace {{classname}} {
{{#vars}} {{#vars}}
{{#isEnum}} {{#isEnum}}

View File

@ -27,7 +27,7 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
} }
{{#hasEnums}} {{#hasEnums}}
export module {{classname}} { export namespace {{classname}} {
{{#vars}} {{#vars}}
{{#isEnum}} {{#isEnum}}
export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}} export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}}
@ -157,15 +157,15 @@ export class {{classname}} {
{{#operation}} {{#operation}}
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : Promise<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }> { 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}} {{#pathParams}}
path = path.replace('{' + '{{baseName}}' + '}', String({{paramName}})); path = path.replace('{' + '{{baseName}}' + '}', String({{paramName}}));
{{/pathParams}} {{/pathParams}}
var queryParameters: any = {}; let queryParameters: any = {};
var headerParams: any = {}; let headerParams: any = {};
var formParams: any = {}; let formParams: any = {};
{{#allParams}}{{#required}} {{#allParams}}{{#required}}
// verify required parameter '{{paramName}}' is set // verify required parameter '{{paramName}}' is set
@ -183,7 +183,7 @@ export class {{classname}} {
headerParams['{{baseName}}'] = {{paramName}}; headerParams['{{baseName}}'] = {{paramName}};
{{/headerParams}} {{/headerParams}}
var useFormData = false; let useFormData = false;
{{#formParams}} {{#formParams}}
if ({{paramName}} !== undefined) { if ({{paramName}} !== undefined) {
@ -194,9 +194,9 @@ export class {{classname}} {
{{/isFile}} {{/isFile}}
{{/formParams}} {{/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}}', method: '{{httpMethod}}',
qs: queryParameters, qs: queryParameters,
headers: headerParams, headers: headerParams,