forked from loafle/openapi-generator-original
Support binary input and output (for body parameters or responses with type "string" and format "binary". Implemented for Java.
This commit is contained in:
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
|
||||
public class CodegenParameter {
|
||||
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
|
||||
isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam;
|
||||
isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam, isBinary;
|
||||
public String baseName, paramName, dataType, collectionFormat, description, baseType, defaultValue;
|
||||
public String jsonSchema;
|
||||
public boolean isEnum;
|
||||
|
||||
@@ -15,6 +15,7 @@ public class CodegenResponse {
|
||||
public Boolean primitiveType;
|
||||
public Boolean isMapContainer;
|
||||
public Boolean isListContainer;
|
||||
public Boolean isBinary;
|
||||
public Object schema;
|
||||
public String jsonSchema;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import io.swagger.models.parameters.SerializableParameter;
|
||||
import io.swagger.models.properties.AbstractNumericProperty;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.BooleanProperty;
|
||||
import io.swagger.models.properties.ByteArrayProperty;
|
||||
import io.swagger.models.properties.DateProperty;
|
||||
import io.swagger.models.properties.DateTimeProperty;
|
||||
import io.swagger.models.properties.DecimalProperty;
|
||||
@@ -311,6 +312,8 @@ public class DefaultCodegen {
|
||||
typeMapping.put("double", "Double");
|
||||
typeMapping.put("object", "Object");
|
||||
typeMapping.put("integer", "Integer");
|
||||
typeMapping.put("ByteArray", "byte[]");
|
||||
|
||||
|
||||
instantiationTypes = new HashMap<String, String>();
|
||||
|
||||
@@ -447,6 +450,8 @@ public class DefaultCodegen {
|
||||
String datatype = null;
|
||||
if (p instanceof StringProperty) {
|
||||
datatype = "string";
|
||||
} else if (p instanceof ByteArrayProperty) {
|
||||
datatype = "ByteArray";
|
||||
} else if (p instanceof BooleanProperty) {
|
||||
datatype = "boolean";
|
||||
} else if (p instanceof DateProperty) {
|
||||
@@ -974,6 +979,7 @@ public class DefaultCodegen {
|
||||
}
|
||||
}
|
||||
r.dataType = cm.datatype;
|
||||
r.isBinary = cm.datatype.equals("byte[]");
|
||||
if (cm.isContainer != null) {
|
||||
r.simpleType = false;
|
||||
r.containerType = cm.containerType;
|
||||
@@ -1070,12 +1076,17 @@ public class DefaultCodegen {
|
||||
p.dataType = getTypeDeclaration(cm.classname);
|
||||
imports.add(p.dataType);
|
||||
} else {
|
||||
// TODO: missing format, so this will not always work
|
||||
Property prop = PropertyBuilder.build(impl.getType(), null, null);
|
||||
Property prop = PropertyBuilder.build(impl.getType(), impl.getFormat(), null);
|
||||
prop.setRequired(bp.getRequired());
|
||||
CodegenProperty cp = fromProperty("property", prop);
|
||||
if (cp != null) {
|
||||
p.dataType = cp.datatype;
|
||||
if (p.dataType.equals("byte[]")) {
|
||||
p.isBinary = true;
|
||||
}
|
||||
else {
|
||||
p.isBinary = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (model instanceof ArrayModel) {
|
||||
|
||||
@@ -66,7 +66,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float",
|
||||
"Object")
|
||||
"Object",
|
||||
"byte[]")
|
||||
);
|
||||
instantiationTypes.put("array", "ArrayList");
|
||||
instantiationTypes.put("map", "HashMap");
|
||||
@@ -282,7 +283,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
return toModelName(type);
|
||||
return type;
|
||||
}
|
||||
} else {
|
||||
type = swaggerType;
|
||||
@@ -379,6 +380,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public void setLocalVariablePrefix(String localVariablePrefix) {
|
||||
this.localVariablePrefix = localVariablePrefix;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getSerializableModel() {
|
||||
return serializableModel;
|
||||
|
||||
Reference in New Issue
Block a user