Open marosrojis opened 1 year ago
This is almost the same issue with the spring-kotlin generator. However, it uses Springs Resource class, that is what you want when downloading the file, but it does not work when uploading. I managed to get it to work by using a typemapping from the Resource class to the MultipartFile class, but then that broke downloading, which must use Resource...
Use type mapping for it, like this:
openapi {
server(file("swagger.yml")) {
typeMapping = [
file : "StreamingFileUpload"
]
}
}
Or set StreamingFileUpload
as schema type:
multipart/form-data:
schema:
type: object
properties:
file:
type: StreamingFileUpload
format: binary
Just use official micronaut generator for java and kotlin by micronaut-opeanpi gradle or maven plugin from this repo: https://github.com/micronaut-projects/micronaut-openapi
Look to this guide: https://guides.micronaut.io/latest/micronaut-openapi-generator-server.html
Also, please describe problems and suggestions here: https://github.com/micronaut-projects/micronaut-openapi/issues
Bug Report Checklist
Description
If the Micronaut endpoint returns a binary file, micronaut uses object types SystemFile or StreamedFile. But the problem is, if the Openapi definition has
format: binary
, the generated endpoint returns object CompletedFileUpload. This object is uses to upload file using multipart, but not to download the file.openapi-generator version
I use the latest version OpenAPI Generator with maven plugin v6.6.0.
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
application/octet-stream
and schema formatbinary
.java-micronaut-server
.Related issues/PRs
Related ticket to generate OpenAPI definition from the implementation and swagger annotations - https://github.com/micronaut-projects/micronaut-openapi/issues/441