Fix TypeScript node file upload

This commit is contained in:
Mads Mætzke Tandrup 2015-07-25 22:05:29 +02:00
parent b0f6b49595
commit fea8e680df
No known key found for this signature in database
GPG Key ID: 67056F406C84B14B
2 changed files with 27 additions and 4 deletions

View File

@ -122,6 +122,8 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return "{ [key: string]: "+ getTypeDeclaration(inner) + "; }";
} else if (p instanceof FileProperty) {
return "any";
}
return super.getTypeDeclaration(p);
}

View File

@ -67,6 +67,7 @@ export class {{classname}} {
{{/pathParams}}
var queryParameters: any = {};
var headerParams: any = {};
var formParams: any = {};
{{#allParams}}
{{#required}}
@ -87,19 +88,39 @@ export class {{classname}} {
headerParams['{{paramName}}'] = {{paramName}};
{{/headerParams}}
var useFormData = false;
{{#formParams}}
if ({{paramName}} !== undefined) {
formParams['{{paramName}}'] = {{paramName}};
}
{{#isFile}}
useFormData = true;
{{/isFile}}
{{/formParams}}
var deferred = promise.defer<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }>();
request({
var requestOptions: any = {
method: '{{httpMethod}}',
qs: queryParameters,
uri: path,
json: true,
{{#bodyParam}}body: {{paramName}},
{{/bodyParam}}
{{#bodyParam}}
body: {{paramName}},
{{/bodyParam}}
auth: {
username: this.username, password: this.password
}
}, (error, response, body) => {
}
if (useFormData) {
requestOptions.formData = formParams;
} else {
requestOptions.form = formParams;
}
request(requestOptions, (error, response, body) => {
if (error) {
deferred.reject(error);
} else {