forked from loafle/openapi-generator-original
Add file response support for typescript-node
This commit is contained in:
parent
e14be8bab9
commit
ed1b6075e9
@ -1,5 +1,7 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.models.properties.FileProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -27,6 +29,8 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
public TypeScriptNodeClientCodegen() {
|
||||
super();
|
||||
|
||||
typeMapping.put("file", "Buffer");
|
||||
|
||||
// clear import mapping (from default generator) as TS does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
@ -92,6 +96,19 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
return "Generates a TypeScript nodejs client library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDataTypeFile(final String dataType) {
|
||||
return dataType != null && dataType.equals("Buffer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if (p instanceof FileProperty) {
|
||||
return "Buffer";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
|
||||
public void setNpmName(String npmName) {
|
||||
this.npmName = npmName;
|
||||
|
@ -235,7 +235,12 @@ export class {{classname}} {
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
useQuerystring: this._useQuerystring,
|
||||
{{^isResponseFile}}
|
||||
json: true,
|
||||
{{/isResponseFile}}
|
||||
{{#isResponseFile}}
|
||||
encoding: null,
|
||||
{{/isResponseFile}}
|
||||
{{#bodyParam}}
|
||||
body: {{paramName}},
|
||||
{{/bodyParam}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user