Skip to content

Commit

Permalink
Handle the schema types 'file' and 'binary' identical
Browse files Browse the repository at this point in the history
  • Loading branch information
lion7 committed Sep 26, 2018
1 parent 77cc2f2 commit 1af40b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ private static String getTypeOfSchema(Schema schema) {
} else if (schema instanceof BinarySchema) {
return SchemaTypeUtil.BINARY_FORMAT;
} else if (schema instanceof FileSchema) {
return "file";
return "file"; // FIXME: this type does not exist in the OpenAPI 3.0 specification
} else if (schema instanceof BooleanSchema) {
return SchemaTypeUtil.BOOLEAN_TYPE;
} else if (schema instanceof DateSchema) {
Expand Down Expand Up @@ -1528,12 +1528,9 @@ public CodegenProperty fromProperty(String name, Schema propertySchema) {
codegenProperty.getVendorExtensions().put(CodegenConstants.IS_BOOLEAN_EXT_NAME, Boolean.TRUE);
codegenProperty.getter = toBooleanGetter(name);
}
if (propertySchema instanceof BinarySchema) {
codegenProperty.getVendorExtensions().put(CodegenConstants.IS_BINARY_EXT_NAME, Boolean.TRUE);
codegenProperty.getVendorExtensions().put(CodegenConstants.IS_STRING_EXT_NAME, Boolean.TRUE);
}
if (propertySchema instanceof FileSchema) {
if (propertySchema instanceof FileSchema || propertySchema instanceof BinarySchema) {
codegenProperty.getVendorExtensions().put(CodegenConstants.IS_FILE_EXT_NAME, Boolean.TRUE);
codegenProperty.getVendorExtensions().put(CodegenConstants.IS_BINARY_EXT_NAME, Boolean.TRUE);
codegenProperty.getVendorExtensions().put(CodegenConstants.IS_STRING_EXT_NAME, Boolean.TRUE);
}
if (propertySchema instanceof EmailSchema) {
Expand Down Expand Up @@ -2264,7 +2261,8 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports)
codegenProperty = codegenProperty.items;
}
collectionFormat = getCollectionFormat(parameter);
} else if (parameterSchema instanceof FileSchema) {
} else if (parameterSchema instanceof FileSchema || parameterSchema instanceof BinarySchema) {
codegenParameter.getVendorExtensions().put(CodegenConstants.IS_BINARY_EXT_NAME, Boolean.TRUE);
codegenParameter.getVendorExtensions().put(CodegenConstants.IS_FILE_EXT_NAME, Boolean.TRUE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.swagger.codegen.v3.SupportingFile;
import io.swagger.codegen.v3.utils.SemVer;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.BinarySchema;
import io.swagger.v3.oas.models.media.FileSchema;
import io.swagger.v3.oas.models.media.MapSchema;
import io.swagger.v3.oas.models.media.ObjectSchema;
Expand Down Expand Up @@ -182,7 +183,7 @@ public String getTypeDeclaration(Schema propertySchema) {
} else if(propertySchema instanceof MapSchema && propertySchema.getAdditionalProperties() != null) {
inner = (Schema) propertySchema.getAdditionalProperties();
return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }";
} else if(propertySchema instanceof FileSchema) {
} else if(propertySchema instanceof FileSchema || propertySchema instanceof BinarySchema) {
return "Blob";
} else if(propertySchema instanceof ObjectSchema) {
return "any";
Expand Down

0 comments on commit 1af40b2

Please sign in to comment.