mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-07 08:00:50 +00:00
ES6-ify typescript promises, update tests, remove bluebird dependency in favor of ES6 promises
This commit is contained in:
parent
3fba32573c
commit
6c3701a403
@ -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_{{.}} = <any> '{{.}}'{{^-last}},{{/-last}}{{/values}}{{/allowableValues}}
|
||||
{{datatypeWithEnum}}_{{.}} = <any> '{{.}}'{{^-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);
|
||||
|
@ -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": {
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user