|
83 | 83 | import java.nio.charset.StandardCharsets;
|
84 | 84 | import java.util.ArrayList;
|
85 | 85 | import java.util.Arrays;
|
| 86 | +import java.util.Collection; |
86 | 87 | import java.util.Collections;
|
87 | 88 | import java.util.Comparator;
|
88 | 89 | import java.util.HashMap;
|
@@ -2338,6 +2339,9 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) {
|
2338 | 2339 | } else {
|
2339 | 2340 | codegenResponse.baseType = codegenProperty.baseType;
|
2340 | 2341 | }
|
| 2342 | + if (isFileTypeSchema(responseSchema)) { |
| 2343 | + codegenResponse.getVendorExtensions().put(CodegenConstants.IS_FILE_EXT_NAME, Boolean.TRUE); |
| 2344 | + } |
2341 | 2345 | }
|
2342 | 2346 | codegenResponse.dataType = codegenProperty.datatype;
|
2343 | 2347 |
|
@@ -4403,6 +4407,21 @@ protected void setParameterNullable(CodegenParameter parameter, CodegenProperty
|
4403 | 4407 | parameter.nullable = property.nullable;
|
4404 | 4408 | }
|
4405 | 4409 |
|
| 4410 | + protected boolean isFileTypeSchema(Schema schema) { |
| 4411 | + final Schema fileTypeSchema; |
| 4412 | + if (StringUtils.isNotBlank(schema.get$ref())) { |
| 4413 | + fileTypeSchema = OpenAPIUtil.getSchemaFromRefSchema(schema, openAPI); |
| 4414 | + } else { |
| 4415 | + fileTypeSchema = schema; |
| 4416 | + } |
| 4417 | + if (fileTypeSchema.getProperties() != null) { |
| 4418 | + final Collection<Schema> propertySchemas = fileTypeSchema.getProperties().values(); |
| 4419 | + return propertySchemas.stream().anyMatch(propertySchema -> "string".equalsIgnoreCase(propertySchema.getType()) |
| 4420 | + && "binary".equalsIgnoreCase(propertySchema.getFormat())); |
| 4421 | + } |
| 4422 | + return false; |
| 4423 | + } |
| 4424 | + |
4406 | 4425 | @Override
|
4407 | 4426 | public boolean needsUnflattenedSpec() {
|
4408 | 4427 | return false;
|
|
0 commit comments