I'm unable to generate an open api generated Feign client for File upload.
This is a snippet of the open api requestBodies component I'm trying to use to upload an array of files
requestBodies:
FilesRequestBody:
description: Array of files
content:
multipart/form-data:
schema:
type: object
properties:
files:
type: array
items:
type: file
my pom file contains the following plugin settings
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.2.3</version>
<executions>
<execution>
<id>generate-feign-client</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.build.directory}/contract/api.yaml</inputSpec>
<language>java</language>
<output>${project.build.directory}/generated-sources</output>
<library>feign</library>
<typeMappings>
<mapping>file=File</mapping>
</typeMappings>
</configuration>
</execution>
notice the typeMappings configuration - which doesn't work.
Ideally I'd like a generated Feign client which looks something like..
import feign.Param;
import feign.RequestLine;
import java.io.File;
public interface ImagesApi {
@RequestLine("POST /api/images")
@Headers({
"Content-Type: multipart/form-data",
"Accept: application/json"
})
List<Image> uploadImages(@Param("config") List<File> files);
}
However, this is generated, which obviously doesn't compile
@RequestLine("POST /api/images")
@Headers({
"Content-Type: multipart/form-data",
"Accept: application/json",
})
List<Image> uploadImages(UNKNOWN_BASE_TYPE UNKNOWN_BASE_TYPE);
any ideas how I can make the maven plugin use a Java Type like java.io.File ?
The issue has been fixed in OpenAPI Generator v6.0.0 release: https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.0.0. Please give it a try.