Beautify typescript angular output

This commit is contained in:
Mads Mætzke Tandrup 2015-07-24 10:14:42 +02:00
parent 88ed496b44
commit bc8eae838c
No known key found for this signature in database
GPG Key ID: 67056F406C84B14B

View File

@ -6,11 +6,11 @@
module {{package}} { module {{package}} {
'use strict'; 'use strict';
{{#description}} {{#description}}
/** /**
* {{&description}} * {{&description}}
*/ */
{{/description}} {{/description}}
export class {{classname}} { export class {{classname}} {
private basePath = '{{contextPath}}'; private basePath = '{{contextPath}}';
@ -21,24 +21,37 @@ module {{package}} {
this.basePath = basePath; this.basePath = basePath;
} }
} }
{{#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}}'; var path = this.basePath + '{{path}}';
{{#pathParams}}
{{#pathParams}}
path = path.replace('{' + '{{paramName}}' + '}', String({{paramName}})); path = path.replace('{' + '{{paramName}}' + '}', String({{paramName}}));
{{/pathParams}}
{{/pathParams}}
var queryParameters: any = {}; var queryParameters: any = {};
var headerParams: any = {}; var headerParams: any = {};
{{#allParams}}{{#required}}
{{#allParams}}
{{#required}}
// verify required parameter '{{paramName}}' is set // verify required parameter '{{paramName}}' is set
if (!{{paramName}}) { if (!{{paramName}}) {
throw new Error('Missing required parameter {{paramName}} when calling {{nickname}}'); 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}}; queryParameters['{{paramName}}'] = {{paramName}};
}{{/queryParams}} }
{{#headerParams}}headerParams['{{paramName}}'] = {{paramName}};{{/headerParams}}
{{/queryParams}}
{{#headerParams}}
headerParams['{{paramName}}'] = {{paramName}};
{{/headerParams}}
var httpRequestParams: any = { var httpRequestParams: any = {
method: '{{httpMethod}}', method: '{{httpMethod}}',
url: path, url: path,
@ -59,7 +72,7 @@ module {{package}} {
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
{{/operation}} {{/operation}}
} }
} }
{{/operations}} {{/operations}}