fix file, binary array

This commit is contained in:
wing328 2018-03-23 21:17:05 +08:00
parent 7d07458b45
commit 1d09962996
2 changed files with 26 additions and 37 deletions

View File

@ -1601,6 +1601,12 @@ public class DefaultCodegen implements CodegenConfig {
} }
if (p instanceof StringSchema || SchemaTypeUtil.STRING_TYPE.equals(p.getType())) { if (p instanceof StringSchema || SchemaTypeUtil.STRING_TYPE.equals(p.getType())) {
if (p instanceof BinarySchema || SchemaTypeUtil.BINARY_FORMAT.equals(p.getFormat())) {
property.isBinary = true;
} else if (p instanceof FileSchema) {
LOGGER.info("debugging FileSchema: " + property.baseName);
property.isFile = true;
} else {
property.maxLength = p.getMaxLength(); property.maxLength = p.getMaxLength();
property.minLength = p.getMinLength(); property.minLength = p.getMinLength();
property.pattern = toRegularExpression(p.getPattern()); property.pattern = toRegularExpression(p.getPattern());
@ -1621,17 +1627,14 @@ public class DefaultCodegen implements CodegenConfig {
property.allowableValues = allowableValues; property.allowableValues = allowableValues;
} }
} }
}
if (p instanceof BooleanSchema || SchemaTypeUtil.BOOLEAN_TYPE.equals(p.getType())) { if (p instanceof BooleanSchema || SchemaTypeUtil.BOOLEAN_TYPE.equals(p.getType())) {
property.isBoolean = true; property.isBoolean = true;
property.getter = toBooleanGetter(name); property.getter = toBooleanGetter(name);
} }
if (p instanceof BinarySchema || SchemaTypeUtil.BINARY_FORMAT.equals(p.getFormat())) {
property.isBinary = true;
}
if (p instanceof FileSchema) { //TODO revise file and binary
property.isFile = true;
}
if (p instanceof UUIDSchema || SchemaTypeUtil.UUID_FORMAT.equals(p.getFormat())) { if (p instanceof UUIDSchema || SchemaTypeUtil.UUID_FORMAT.equals(p.getFormat())) {
// keep isString to true to make it backward compatible // keep isString to true to make it backward compatible
property.isString =true; property.isString =true;
@ -2587,21 +2590,6 @@ public class DefaultCodegen implements CodegenConfig {
} else { } else {
LOGGER.warn("Unknown parameter type: " + parameter.getName()); LOGGER.warn("Unknown parameter type: " + parameter.getName());
} }
/* TODO: need to fix body parameter and form parameter
else if (parameter instanceof BodyParameter) {
codegenParameter.isBodyParam = true;
codegenParameter.isBinary = isDataTypeBinary(codegenParameter.dataType);
}
else if (parameter instanceof FormParameter) {
if ("file".equalsIgnoreCase(((FormParameter) parameter).getType()) || "file".equals(codegenParameter.baseType)) {
codegenParameter.isFile = true;
} else {
codegenParameter.notFile = true;
}
codegenParameter.isFormParam = true;
}
*/
// set the example value // set the example value
// if not specified in x-example, generate a default value // if not specified in x-example, generate a default value
@ -3930,6 +3918,7 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.unescapedDescription = codegenProperty.getDescription(); codegenParameter.unescapedDescription = codegenProperty.getDescription();
codegenParameter.jsonSchema = Json.pretty(propertySchema); codegenParameter.jsonSchema = Json.pretty(propertySchema);
if (codegenProperty.getVendorExtensions() != null && !codegenProperty.getVendorExtensions().isEmpty()) { if (codegenProperty.getVendorExtensions() != null && !codegenProperty.getVendorExtensions().isEmpty()) {
codegenParameter.vendorExtensions = codegenProperty.getVendorExtensions(); codegenParameter.vendorExtensions = codegenProperty.getVendorExtensions();
} }

View File

@ -606,7 +606,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
} }
} else if ("\\SplFileObject".equalsIgnoreCase(type) || p.isFile) { } else if ("\\SplFileObject".equalsIgnoreCase(type) || p.isFile) {
if (example == null) { if (example == null) {
example = "/path/to/file"; example = "/path/to/file.txt";
} }
example = "\"" + escapeText(example) + "\""; example = "\"" + escapeText(example) + "\"";
} else if ("\\Date".equalsIgnoreCase(type)) { } else if ("\\Date".equalsIgnoreCase(type)) {