Bug Report Checklist
Description
I have a simple OpenAPI specification (external openapi, I cannot change it):
paths:
/download:
get:
summary: Download file
operationId: downloadFile
parameters:
- name: fileName
in: query
description: File name
required: true
schema:
type: string
responses:
"200":
description: Success
content:
application/octet-stream:
schema:
type: string
format: binary
"4XX":
description: Failure
content:
application/json:
schema:
$ref: "#/components/schemas/errorResponse"
I generate code client with openapi-generator-maven-plugin 7.22.0 and try to download file via the generated client in my unit test:
@Test
void downloadProblem() {
File ok = defaultApi.downloadFile("ok");
assertThat(ok).exists();
}
I expect the code downloads file successfully, but instead one failed with:
org.springframework.web.client.UnknownContentTypeException: Could not extract response: no suitable HttpMessageConverter found for response type [class java.io.File] and content type [application/octet-stream]
at org.springframework.web.client.DefaultRestClient.readWithMessageConverters(DefaultRestClient.java:251)
at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.readBody(DefaultRestClient.java:826)
at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.lambda$body$1(DefaultRestClient.java:765)
at org.springframework.web.client.DefaultRestClient$DefaultRequestBodyUriSpec.exchangeInternal(DefaultRestClient.java:586)
at org.springframework.web.client.DefaultRestClient$DefaultRequestBodyUriSpec.exchange(DefaultRestClient.java:540)
at org.springframework.web.client.RestClient$RequestHeadersSpec.exchange(RestClient.java:677)
at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.executeAndExtract(DefaultRestClient.java:821)
at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.body(DefaultRestClient.java:765)
openapi-generator version
7.22.0
OpenAPI declaration file content or url
https://github.com/anatoly-spb/openapi-octet-stream-problem/blob/main/src/main/resources/downloader.yaml
Generation Details
https://github.com/anatoly-spb/openapi-octet-stream-problem/blob/main/pom.xml#L109
Steps to reproduce
Related issues/PRs
Suggest a fix
Bug Report Checklist
Description
I have a simple OpenAPI specification (external openapi, I cannot change it):
I generate code client with openapi-generator-maven-plugin 7.22.0 and try to download file via the generated client in my unit test:
I expect the code downloads file successfully, but instead one failed with:
openapi-generator version
7.22.0
OpenAPI declaration file content or url
https://github.com/anatoly-spb/openapi-octet-stream-problem/blob/main/src/main/resources/downloader.yaml
Generation Details
https://github.com/anatoly-spb/openapi-octet-stream-problem/blob/main/pom.xml#L109
Steps to reproduce
Related issues/PRs
Suggest a fix