Open BenjGue opened 6 years ago
You probably solved this by now, but for anybody else encountering this issue.
I don't know if there is a fix planned for this, but in the mean time you can add a typeMappings config in you pom.
<configuration>
.....
<typeMappings>
<typeMapping>File=byte[]</typeMapping>
</typeMappings>
</configuration>
I
You probably solved this by now, but for anybody else encountering this issue.
I don't know if there is a fix planned for this, but in the mean time you can add a typeMappings config in you pom.
<configuration> ..... <typeMappings> <typeMapping>File=byte[]</typeMapping> </typeMappings> </configuration>
I am facing similar issue. I am using gradle. is there a way to fix this in gradle
I am using io.swagger.core.v3.swagger-gradle-plugin
Swagger-codegen version
V 3.0.2
Description
I was using swagger 2.0 with mavenplugin-codegen V 2.3.1 : When i have a response type application/octet-stream => Json file : "schema" : { "type" : "string", "format" : "binary"} => Genetares this signature in the Interface API:
@RequestMapping(value = "/addressbooks/export/{addressBookId}", produces = { "application/octet-stream" }, method = RequestMethod.GET) public ResponseEntity<byte[]>
Now i have migrated in openApi3 with mavenplugin-codegen V3.0.2 When i have a response type application/octet-stream => Json file : "content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}} => it generates this signature Interface API : @RequestMapping(value = "/addressbooks/export/{addressBookId}",produces = { "application/octet-stream", "application/json" }, method = RequestMethod.GET) default ResponseEntity< File >
The fact that the response is a File instead of byte[] makes spring raise this exception : "org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation"
Steps to reproduce
Create a openAPi3 with this response : responses: '200': content: application/octet-stream: schema: type: string format: binary
Generate the Json file.
Launch the build with codegen 3.0.2 for spring
Check you have a signature => default ResponseEntity< File >
Try to reach this endpoint
Must get: "org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation"
Related issues/PRs
Suggest a fix/enhancement