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 b93783fc098..a85c170082e 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-node/api.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-node/api.mustache @@ -1,5 +1,4 @@ import request = require('request'); -import promise = require('bluebird'); import http = require('http'); let defaultBasePath = '{{basePath}}'; @@ -24,7 +23,7 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ * {{{description}}} */ {{/description}} - "{{name}}": {{#isEnum}}{{classname}}.{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; + '{{name}}': {{#isEnum}}{{classname}}.{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; {{/vars}} } @@ -33,7 +32,7 @@ export namespace {{classname}} { {{#vars}} {{#isEnum}} export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}} - VALUE_{{.}} = '{{.}}'{{^-last}},{{/-last}}{{/values}}{{/allowableValues}} + {{datatypeWithEnum}}_{{.}} = '{{.}}'{{^-last}},{{/-last}}{{/values}}{{/allowableValues}} } {{/isEnum}} {{/vars}} @@ -184,7 +183,7 @@ export class {{classname}} { * {{notes}} {{#allParams}}* @param {{paramName}} {{description}} {{/allParams}}*/ - public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : Promise<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> { + public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : Promise<{ response: http.IncomingMessage; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> { const localVarPath = this.basePath + '{{path}}'{{#pathParams}} .replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}}; let queryParameters: any = {}; @@ -227,7 +226,7 @@ export class {{classname}} { {{#bodyParam}} body: {{paramName}}, {{/bodyParam}} - } + }; {{#authMethods}} this.authentications.{{name}}.applyToRequest(requestOptions); @@ -243,7 +242,7 @@ export class {{classname}} { } } - return new Promise<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }>((resolve, reject) => { + return new Promise<{ response: http.IncomingMessage; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }>((resolve, reject) => { request(requestOptions, (error, response, body) => { if (error) { reject(error); diff --git a/samples/client/petstore/typescript-angular/package.json b/samples/client/petstore/typescript-angular/package.json index f50b782c09f..0819b27f295 100644 --- a/samples/client/petstore/typescript-angular/package.json +++ b/samples/client/petstore/typescript-angular/package.json @@ -5,12 +5,13 @@ "main": "api.js", "scripts": { "postinstall": "tsd reinstall --overwrite", - "test": "tsc", + "test": "tsc --target ES6 && node client.js", "clean": "rm -Rf node_modules/ typings/ *.js" }, "author": "Mads M. Tandrup", "license": "Apache 2.0", "dependencies": { + "request": "^2.60.0", "angular": "^1.4.3" }, "devDependencies": { diff --git a/samples/client/petstore/typescript-angular/tsd.json b/samples/client/petstore/typescript-angular/tsd.json index 182b9f68fa2..c4cfa3f1bac 100644 --- a/samples/client/petstore/typescript-angular/tsd.json +++ b/samples/client/petstore/typescript-angular/tsd.json @@ -5,11 +5,20 @@ "path": "typings", "bundle": "typings/tsd.d.ts", "installed": { - "angularjs/angular.d.ts": { + "angularjs/angular.d.ts": { "commit": "f6c8ca47193fb67947944a3170912672ac3e908e" }, "jquery/jquery.d.ts": { "commit": "f6c8ca47193fb67947944a3170912672ac3e908e" + }, + "request/request.d.ts": { + "commit": "f6c8ca47193fb67947944a3170912672ac3e908e" + }, + "form-data/form-data.d.ts": { + "commit": "f6c8ca47193fb67947944a3170912672ac3e908e" + }, + "node/node.d.ts": { + "commit": "f6c8ca47193fb67947944a3170912672ac3e908e" } } }