Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #14295
Closed
Open
Issue created Dec 20, 2022 by Administrator@rootContributor

[BUG][JAVA][SERVER] In release 6.2.1, spring server generator creates wrong annotation on method parameter for multipart request

Created by: raverone

Description

Spring server genertor creates wrong annotation on method parameter for multipart request. The request have 2 parameters:

  • SomeObject param1
  • MultipartFile param2

In version 5.4.0 both parameters would be annotated with @RequestPart. Which is correct.

But starting from version 6.0.0 (until the 6.2.1 at least) param1 would be annotated with @RequestParam and param2 with @RequestPart. In this case, if you make a call to such endpoint, Spring won't be able to convert the request parameters and will throw

org.springframework.web.method.annotation.MethodArgumentConversionNotSupportedException:
Failed to convert value of type 'java.lang.String' to required type 'org.example.http.model.SomeObject';
...
no matching editors or conversion strategy found
openapi-generator version

6.2.1

OpenAPI declaration file content or url

Gist

Generation Details

Generation is done with the gradle plugin by executing ./gradlew :openApiGenerate

Steps to reproduce

I created a minimal project on github Steps to reproduce the bug:

  • clone the repo
  • cd into the repo directory
  • execute ./gradlew :openApiGenerate
  • examine file build/generated/src/main/java/org/example/bug/http/api/TestApiApi.java
    • Expected generated code
default ResponseEntity<SomeResponse> uploadFileAndJson(
        @RequestPart(value = "someObject", required = true) SomeObject someObject,
        @RequestPart(value = "image", required = true) MultipartFile image
    )
    • Actual generated code
default ResponseEntity<SomeResponse> uploadFileAndJson(
        @RequestParam(value = "someObject", required = true) SomeObject someObject,
        @RequestPart(value = "image", required = true) MultipartFile image
    )
  • you can also execute tests with ./gradlew -i :test. It should pass, but currently it isn't.
Assignee
Assign to
Time tracking