[BUG][Java][Server:Spring-boot] File upload spec (application/octet-stream) generates MultiPartFile Delegate
Created by: schafdog
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
I am trying to build a simple file upload of any mime-type (application/octet-stream) but the generated code is not valid.
The API class looks right having a Resource body as parameter, but the generated Delegate has a MultipartFile body parameter which is not compatible.
openapi-generator version
I am using version 3.3.4 maven plugin. I haven't tried earlier versions
OpenAPI declaration file content or url
post:
operationId: createResource
summary: Create new resource
description: create a remote resources
requestBody:
content:
application/octet-stream:
schema:
type: string
format: binary
The Delegate parameters does not match the API parameters and thus the generated code does not compile:
default ResponseEntity<CreateResponseBody> ResourceDelegate.createResource(String pathFolderId,
String resourceName,
ResourceType type,
MultipartFile body)
default ResponseEntity<CreateResponseBody> ResourcesApi.createResource(@ApiParam(value = "",required=true) @PathVariable("pathFolderId") String pathFolderId,@ApiParam(value = "",required=true) @PathVariable("resourceName") String resourceName,@ApiParam(value = "", defaultValue = "null") @Valid @RequestParam(value = "type", required = false, defaultValue="null") ResourceType type,@ApiParam(value = "" ) @Valid @RequestBody Resource body) {
return getDelegate().createResource(pathFolderId, resourceName, type, body);
Command line used for generation
Using the maven plugin:
<configuration>
<generatorName>spring</generatorName>
<configOptions>
<interfaceOnly>false</interfaceOnly>
<delegatePattern>true</delegatePattern>
<java8>true</java8>
</configOptions>
<generateSupportingFiles>true</generateSupportingFiles>
</configuration>
Steps to reproduce
Changing the format to base64 creates valid generated code, but not the java methods I am interested in. Changing back to binary and doing a clean build generates again invalid code that doesn't compile.
Related issues/PRs
Suggest a fix
Disabling the generation of Delegate could be a work-around.