Skip to content

Commit

Permalink
Add import java.io.InputStream to generated api client class (#1225)
Browse files Browse the repository at this point in the history
Fixed #1223
  • Loading branch information
altro3 committed Sep 27, 2023
1 parent a04f1f1 commit 47bbb33
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class JavaMicronautClientCodegen extends AbstractMicronautJavaCodegen<Jav

typeMapping.put("file", "byte[]");
typeMapping.put("responseFile", "InputStream");
importMapping.put("InputStream", "java.io.InputStream");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,14 @@ void testDiscriminatorConstructorBug() {
assertFileContains(apiPath + "BasicBookInfo.java", "public BasicBookInfo(String author, String name)", "super(name)");
assertFileContains(apiPath + "DetailedBookInfo.java", "public DetailedBookInfo(String isbn, String name, String author)", "super(author, name)");
}

@Test
void testWrongImportInputStream() {

var codegen = new JavaMicronautClientCodegen();
String outputPath = generateFiles(codegen, "src/test/resources/3_0/inputStream.yml", CodegenConstants.APIS, CodegenConstants.API_TESTS);
String apiPath = outputPath + "src/main/java/org/openapitools/api/";

assertFileContains(apiPath + "DefaultApi.java", "import java.io.InputStream;");
}
}
24 changes: 24 additions & 0 deletions openapi-generator/src/test/resources/3_0/inputStream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
openapi: "3.0.3"
info:
version: "v1"
title: "Dummy"
paths:
/assets:export:
get:
operationId: "Dummy"
description: ""
parameters:
- name: "query"
in: "query"
description: ""
required: false
schema:
type: "string"
responses:
"200":
description: ""
content:
'*/*':
schema:
type: "string"
format: "binary"

0 comments on commit 47bbb33

Please sign in to comment.