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;
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
|
import io.swagger.models.properties.FileProperty;
|
||||||
|
import io.swagger.models.properties.Property;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -27,6 +29,8 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
|||||||
public TypeScriptNodeClientCodegen() {
|
public TypeScriptNodeClientCodegen() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
typeMapping.put("file", "Buffer");
|
||||||
|
|
||||||
// clear import mapping (from default generator) as TS does not use it
|
// clear import mapping (from default generator) as TS does not use it
|
||||||
// at the moment
|
// at the moment
|
||||||
importMapping.clear();
|
importMapping.clear();
|
||||||
@ -92,6 +96,19 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
|||||||
return "Generates a TypeScript nodejs client library.";
|
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) {
|
public void setNpmName(String npmName) {
|
||||||
this.npmName = npmName;
|
this.npmName = npmName;
|
||||||
|
@ -235,7 +235,12 @@ export class {{classname}} {
|
|||||||
headers: headerParams,
|
headers: headerParams,
|
||||||
uri: localVarPath,
|
uri: localVarPath,
|
||||||
useQuerystring: this._useQuerystring,
|
useQuerystring: this._useQuerystring,
|
||||||
|
{{^isResponseFile}}
|
||||||
json: true,
|
json: true,
|
||||||
|
{{/isResponseFile}}
|
||||||
|
{{#isResponseFile}}
|
||||||
|
encoding: null,
|
||||||
|
{{/isResponseFile}}
|
||||||
{{#bodyParam}}
|
{{#bodyParam}}
|
||||||
body: {{paramName}},
|
body: {{paramName}},
|
||||||
{{/bodyParam}}
|
{{/bodyParam}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user