forked from loafle/openapi-generator-original
Support file response schema
This commit is contained in:
parent
0a5b0bb8ce
commit
e14be8bab9
@ -14,7 +14,7 @@ public class CodegenOperation {
|
|||||||
public Boolean hasAuthMethods, hasConsumes, hasProduces, hasParams, hasOptionalParams,
|
public Boolean hasAuthMethods, hasConsumes, hasProduces, hasParams, hasOptionalParams,
|
||||||
returnTypeIsPrimitive, returnSimpleType, subresourceOperation, isMapContainer,
|
returnTypeIsPrimitive, returnSimpleType, subresourceOperation, isMapContainer,
|
||||||
isListContainer, isMultipart, hasMore = Boolean.TRUE,
|
isListContainer, isMultipart, hasMore = Boolean.TRUE,
|
||||||
isResponseBinary = Boolean.FALSE, hasReference = Boolean.FALSE,
|
isResponseBinary = Boolean.FALSE, isResponseFile = Boolean.FALSE, hasReference = Boolean.FALSE,
|
||||||
isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
|
isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
|
||||||
isRestful;
|
isRestful;
|
||||||
public String path, operationId, returnType, httpMethod, returnBaseType,
|
public String path, operationId, returnType, httpMethod, returnBaseType,
|
||||||
@ -215,6 +215,8 @@ public class CodegenOperation {
|
|||||||
return false;
|
return false;
|
||||||
if (isResponseBinary != null ? !isResponseBinary.equals(that.isResponseBinary) : that.isResponseBinary != null)
|
if (isResponseBinary != null ? !isResponseBinary.equals(that.isResponseBinary) : that.isResponseBinary != null)
|
||||||
return false;
|
return false;
|
||||||
|
if (isResponseFile != null ? !isResponseFile.equals(that.isResponseFile) : that.isResponseFile != null)
|
||||||
|
return false;
|
||||||
if (hasReference != null ? !hasReference.equals(that.hasReference) : that.hasReference != null)
|
if (hasReference != null ? !hasReference.equals(that.hasReference) : that.hasReference != null)
|
||||||
return false;
|
return false;
|
||||||
if (path != null ? !path.equals(that.path) : that.path != null)
|
if (path != null ? !path.equals(that.path) : that.path != null)
|
||||||
@ -297,6 +299,7 @@ public class CodegenOperation {
|
|||||||
result = 31 * result + (isMultipart != null ? isMultipart.hashCode() : 0);
|
result = 31 * result + (isMultipart != null ? isMultipart.hashCode() : 0);
|
||||||
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
|
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
|
||||||
result = 31 * result + (isResponseBinary != null ? isResponseBinary.hashCode() : 0);
|
result = 31 * result + (isResponseBinary != null ? isResponseBinary.hashCode() : 0);
|
||||||
|
result = 31 * result + (isResponseFile != null ? isResponseFile.hashCode() : 0);
|
||||||
result = 31 * result + (hasReference != null ? hasReference.hashCode() : 0);
|
result = 31 * result + (hasReference != null ? hasReference.hashCode() : 0);
|
||||||
result = 31 * result + (path != null ? path.hashCode() : 0);
|
result = 31 * result + (path != null ? path.hashCode() : 0);
|
||||||
result = 31 * result + (operationId != null ? operationId.hashCode() : 0);
|
result = 31 * result + (operationId != null ? operationId.hashCode() : 0);
|
||||||
|
@ -37,7 +37,7 @@ public class CodegenProperty implements Cloneable {
|
|||||||
public Boolean hasMore, required, secondaryParam;
|
public Boolean hasMore, required, secondaryParam;
|
||||||
public Boolean hasMoreNonReadOnly; // for model constructor, true if next properyt is not readonly
|
public Boolean hasMoreNonReadOnly; // for model constructor, true if next properyt is not readonly
|
||||||
public Boolean isPrimitiveType, isContainer, isNotContainer;
|
public Boolean isPrimitiveType, isContainer, isNotContainer;
|
||||||
public Boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
|
public Boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isFile, isBoolean, isDate, isDateTime;
|
||||||
public Boolean isListContainer, isMapContainer;
|
public Boolean isListContainer, isMapContainer;
|
||||||
public boolean isEnum;
|
public boolean isEnum;
|
||||||
public Boolean isReadOnly = false;
|
public Boolean isReadOnly = false;
|
||||||
@ -108,6 +108,7 @@ public class CodegenProperty implements Cloneable {
|
|||||||
result = prime * result + ((isDouble == null) ? 0 : isDouble.hashCode());
|
result = prime * result + ((isDouble == null) ? 0 : isDouble.hashCode());
|
||||||
result = prime * result + ((isByteArray == null) ? 0 : isByteArray.hashCode());
|
result = prime * result + ((isByteArray == null) ? 0 : isByteArray.hashCode());
|
||||||
result = prime * result + ((isBinary == null) ? 0 : isBinary.hashCode());
|
result = prime * result + ((isBinary == null) ? 0 : isBinary.hashCode());
|
||||||
|
result = prime * result + ((isFile == null) ? 0 : isFile.hashCode());
|
||||||
result = prime * result + ((isBoolean == null) ? 0 : isBoolean.hashCode());
|
result = prime * result + ((isBoolean == null) ? 0 : isBoolean.hashCode());
|
||||||
result = prime * result + ((isDate == null) ? 0 : isDate.hashCode());
|
result = prime * result + ((isDate == null) ? 0 : isDate.hashCode());
|
||||||
result = prime * result + ((isDateTime == null) ? 0 : isDateTime.hashCode());
|
result = prime * result + ((isDateTime == null) ? 0 : isDateTime.hashCode());
|
||||||
@ -264,6 +265,9 @@ public class CodegenProperty implements Cloneable {
|
|||||||
if (this.isBinary != other.isBinary && (this.isBinary == null || !this.isBinary.equals(other.isBinary))) {
|
if (this.isBinary != other.isBinary && (this.isBinary == null || !this.isBinary.equals(other.isBinary))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this.isFile != other.isFile && (this.isFile == null || !this.isFile.equals(other.isFile))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (this.isListContainer != other.isListContainer && (this.isListContainer == null || !this.isListContainer.equals(other.isListContainer))) {
|
if (this.isListContainer != other.isListContainer && (this.isListContainer == null || !this.isListContainer.equals(other.isListContainer))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ public class CodegenResponse {
|
|||||||
public Boolean isMapContainer;
|
public Boolean isMapContainer;
|
||||||
public Boolean isListContainer;
|
public Boolean isListContainer;
|
||||||
public Boolean isBinary = Boolean.FALSE;
|
public Boolean isBinary = Boolean.FALSE;
|
||||||
|
public Boolean isFile = Boolean.FALSE;
|
||||||
public Object schema;
|
public Object schema;
|
||||||
public String jsonSchema;
|
public String jsonSchema;
|
||||||
|
|
||||||
@ -63,6 +64,8 @@ public class CodegenResponse {
|
|||||||
return false;
|
return false;
|
||||||
if (isBinary != null ? !isBinary.equals(that.isBinary) : that.isBinary != null)
|
if (isBinary != null ? !isBinary.equals(that.isBinary) : that.isBinary != null)
|
||||||
return false;
|
return false;
|
||||||
|
if (isFile != null ? !isFile.equals(that.isFile) : that.isFile != null)
|
||||||
|
return false;
|
||||||
if (schema != null ? !schema.equals(that.schema) : that.schema != null)
|
if (schema != null ? !schema.equals(that.schema) : that.schema != null)
|
||||||
return false;
|
return false;
|
||||||
return jsonSchema != null ? jsonSchema.equals(that.jsonSchema) : that.jsonSchema == null;
|
return jsonSchema != null ? jsonSchema.equals(that.jsonSchema) : that.jsonSchema == null;
|
||||||
@ -85,6 +88,7 @@ public class CodegenResponse {
|
|||||||
result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0);
|
result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0);
|
||||||
result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0);
|
result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0);
|
||||||
result = 31 * result + (isBinary != null ? isBinary.hashCode() : 0);
|
result = 31 * result + (isBinary != null ? isBinary.hashCode() : 0);
|
||||||
|
result = 31 * result + (isFile != null ? isFile.hashCode() : 0);
|
||||||
result = 31 * result + (schema != null ? schema.hashCode() : 0);
|
result = 31 * result + (schema != null ? schema.hashCode() : 0);
|
||||||
result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0);
|
result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0);
|
||||||
return result;
|
return result;
|
||||||
|
@ -36,6 +36,7 @@ import io.swagger.models.properties.DateProperty;
|
|||||||
import io.swagger.models.properties.DateTimeProperty;
|
import io.swagger.models.properties.DateTimeProperty;
|
||||||
import io.swagger.models.properties.DecimalProperty;
|
import io.swagger.models.properties.DecimalProperty;
|
||||||
import io.swagger.models.properties.DoubleProperty;
|
import io.swagger.models.properties.DoubleProperty;
|
||||||
|
import io.swagger.models.properties.FileProperty;
|
||||||
import io.swagger.models.properties.FloatProperty;
|
import io.swagger.models.properties.FloatProperty;
|
||||||
import io.swagger.models.properties.IntegerProperty;
|
import io.swagger.models.properties.IntegerProperty;
|
||||||
import io.swagger.models.properties.LongProperty;
|
import io.swagger.models.properties.LongProperty;
|
||||||
@ -765,6 +766,7 @@ public class DefaultCodegen {
|
|||||||
typeMapping.put("integer", "Integer");
|
typeMapping.put("integer", "Integer");
|
||||||
typeMapping.put("ByteArray", "byte[]");
|
typeMapping.put("ByteArray", "byte[]");
|
||||||
typeMapping.put("binary", "byte[]");
|
typeMapping.put("binary", "byte[]");
|
||||||
|
typeMapping.put("file", "File");
|
||||||
|
|
||||||
|
|
||||||
instantiationTypes = new HashMap<String, String>();
|
instantiationTypes = new HashMap<String, String>();
|
||||||
@ -1069,6 +1071,8 @@ public class DefaultCodegen {
|
|||||||
datatype = "ByteArray";
|
datatype = "ByteArray";
|
||||||
} else if (p instanceof BinaryProperty) {
|
} else if (p instanceof BinaryProperty) {
|
||||||
datatype = "binary";
|
datatype = "binary";
|
||||||
|
} else if (p instanceof FileProperty) {
|
||||||
|
datatype = "file";
|
||||||
} else if (p instanceof BooleanProperty) {
|
} else if (p instanceof BooleanProperty) {
|
||||||
datatype = "boolean";
|
datatype = "boolean";
|
||||||
} else if (p instanceof DateProperty) {
|
} else if (p instanceof DateProperty) {
|
||||||
@ -1536,6 +1540,9 @@ public class DefaultCodegen {
|
|||||||
if (p instanceof BinaryProperty) {
|
if (p instanceof BinaryProperty) {
|
||||||
property.isBinary = true;
|
property.isBinary = true;
|
||||||
}
|
}
|
||||||
|
if (p instanceof FileProperty) {
|
||||||
|
property.isFile = true;
|
||||||
|
}
|
||||||
if (p instanceof UUIDProperty) {
|
if (p instanceof UUIDProperty) {
|
||||||
property.isString = true;
|
property.isString = true;
|
||||||
}
|
}
|
||||||
@ -1964,6 +1971,9 @@ public class DefaultCodegen {
|
|||||||
if (r.isBinary && r.isDefault){
|
if (r.isBinary && r.isDefault){
|
||||||
op.isResponseBinary = Boolean.TRUE;
|
op.isResponseBinary = Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
if (r.isFile && r.isDefault){
|
||||||
|
op.isResponseFile = Boolean.TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
op.responses.get(op.responses.size() - 1).hasMore = false;
|
op.responses.get(op.responses.size() - 1).hasMore = false;
|
||||||
|
|
||||||
@ -2163,6 +2173,7 @@ public class DefaultCodegen {
|
|||||||
}
|
}
|
||||||
r.dataType = cm.datatype;
|
r.dataType = cm.datatype;
|
||||||
r.isBinary = isDataTypeBinary(cm.datatype);
|
r.isBinary = isDataTypeBinary(cm.datatype);
|
||||||
|
r.isFile = isDataTypeFile(cm.datatype);
|
||||||
if (cm.isContainer != null) {
|
if (cm.isContainer != null) {
|
||||||
r.simpleType = false;
|
r.simpleType = false;
|
||||||
r.containerType = cm.containerType;
|
r.containerType = cm.containerType;
|
||||||
@ -2345,6 +2356,7 @@ public class DefaultCodegen {
|
|||||||
p.dataType = cp.datatype;
|
p.dataType = cp.datatype;
|
||||||
p.isPrimitiveType = cp.isPrimitiveType;
|
p.isPrimitiveType = cp.isPrimitiveType;
|
||||||
p.isBinary = isDataTypeBinary(cp.datatype);
|
p.isBinary = isDataTypeBinary(cp.datatype);
|
||||||
|
p.isFile = isDataTypeFile(cp.datatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set boolean flag (e.g. isString)
|
// set boolean flag (e.g. isString)
|
||||||
@ -2412,6 +2424,8 @@ public class DefaultCodegen {
|
|||||||
p.example = "BINARY_DATA_HERE";
|
p.example = "BINARY_DATA_HERE";
|
||||||
} else if (Boolean.TRUE.equals(p.isByteArray)) {
|
} else if (Boolean.TRUE.equals(p.isByteArray)) {
|
||||||
p.example = "B";
|
p.example = "B";
|
||||||
|
} else if (Boolean.TRUE.equals(p.isFile)) {
|
||||||
|
p.example = "/path/to/file.txt";
|
||||||
} else if (Boolean.TRUE.equals(p.isDate)) {
|
} else if (Boolean.TRUE.equals(p.isDate)) {
|
||||||
p.example = "2013-10-20";
|
p.example = "2013-10-20";
|
||||||
} else if (Boolean.TRUE.equals(p.isDateTime)) {
|
} else if (Boolean.TRUE.equals(p.isDateTime)) {
|
||||||
@ -2462,6 +2476,10 @@ public class DefaultCodegen {
|
|||||||
return dataType.toLowerCase().startsWith("byte");
|
return dataType.toLowerCase().startsWith("byte");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDataTypeFile(String dataType) {
|
||||||
|
return dataType.toLowerCase().equals("file");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert map of Swagger SecuritySchemeDefinition objects to a list of Codegen Security objects
|
* Convert map of Swagger SecuritySchemeDefinition objects to a list of Codegen Security objects
|
||||||
*
|
*
|
||||||
@ -3257,6 +3275,9 @@ public class DefaultCodegen {
|
|||||||
} else if (Boolean.TRUE.equals(property.isBinary)) {
|
} else if (Boolean.TRUE.equals(property.isBinary)) {
|
||||||
parameter.isByteArray = true;
|
parameter.isByteArray = true;
|
||||||
parameter.isPrimitiveType = true;
|
parameter.isPrimitiveType = true;
|
||||||
|
} else if (Boolean.TRUE.equals(property.isFile)) {
|
||||||
|
parameter.isFile = true;
|
||||||
|
parameter.isPrimitiveType = true;
|
||||||
} else if (Boolean.TRUE.equals(property.isDate)) {
|
} else if (Boolean.TRUE.equals(property.isDate)) {
|
||||||
parameter.isDate = true;
|
parameter.isDate = true;
|
||||||
parameter.isPrimitiveType = true;
|
parameter.isPrimitiveType = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user