Open anuhyapolisetti opened 5 years ago
👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
I'm experiencing the same problem with version 4.1.3 (in a JHipster API-first project).
operation:
/attachments:
post:
description: Creates a new Attachment by a file upload
operationId: createAttachment
requestBody:
content:
application/octet-stream:
schema:
$ref: '#/components/schemas/AttachmentFile'
schema:
AttachmentFile:
type: string
format: binary
generated "...ApiDelegate" interface method:
default ResponseEntity<Attachment> createAttachment(MultipartFile body) { ... }
generated "...Api" interface method:
default ResponseEntity<Attachment> createAttachment(@ApiParam(value = "" ) @Valid @RequestBody Resource body) {
return getDelegate().createAttachment(body);
}
I'm dropping this workaround just in case:
Define typeMapping
in pom.xml
(or analogous Gradle config):
<typeMappings>binary-string=org.springframework.core.io.Resource</typeMappings>
and use binary-string
in the OpenAPI specification:
requestBody:
content:
application/octet-stream:
schema:
type: binary-string
<typeMappings>binary-string=org.springframework.core.io.Resource</typeMappings>
Life saver my guy, I've been looking all over for a workaround as this issue is still present in 5.4.0
Bug Report Checklist
Description
We have encountered this problem generated Api and ApiDelegate files have different request body types (Resource/MultipartFile), which is resulting in compilation errors.
Issue seemed to have addressed in v4.0.0-beta3 version, but issue still persists when we tried with the cli version of v4.0.0-beta3.
openapi-generator version
v4.0.2
OpenAPI declaration file content or url
Command line used for generation
java -jar openapi-generator-cli.jar generate -g spring -i api.yml -o ./out --additional-properties delegatePattern=true
Steps to reproduce
Run the command above with provided api.yml.
Open out/src/main/java/org/openapitools/api/FooApi.java, look at generated
foo
methodOpen out/src/main/java/org/openapitools/api/FooApiDelegate.java, look at generated apiDelegate method
foo
from FooApiDelegate consumesMultipartFile
whereas FooApi passesResource
as request body type.Related issues/PRs
Issue seemed to have addressed in v4.0.0-beta3 version per above PR, but issue still persists when we tried with the cli version of v4.0.0-beta3.
Suggest a fix
Use either Multipartfile or Resource in both api and apidelegate