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
  • #14449
Closed
Open
Issue created Jan 13, 2023 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][JAVA][SPRING] Wrong annotation used for array of referenced object in Multipart request

Created by: MetroMarv

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When we specify the request body as multipart/form-data and have one property of type array.

The generated annotation for the statusArray property is "@RequestParam". Which leads to following error in Spring when the endpoint is used:

org.springframework.web.method.annotation.MethodArgumentConversionNotSupportedException:
Failed to convert value of type 'java.lang.String' to required type 'List.of<MultipartMixedStatus>';

Expected would be the annotation "@RequestPart" which fixes the Spring error.

openapi-generator version

6.2.1

But the problem was probably introduced in #11449 with version 6.0.0 (thanks to @borsch to figure this out)

OpenAPI declaration file content or url
[...]
requestBody:
  content:
    multipart/form-data:
      schema:
        type: object
        properties:
          file:
            description: "a file"
            type: string
            format: binary
          statusArray:
            type: array
            items:
              $ref: '#/components/schemas/MultipartMixedStatus'
[...]
Generation Details

We used the Maven plugin with following config

        <configuration>
          <templateDirectory>openapi-generator-customization</templateDirectory>
          <generatorName>spring</generatorName>
          <modelNameSuffix>Dto</modelNameSuffix>
          <configOptions>
            <useSpringBoot3>true</useSpringBoot3>
            <documentationProvider>springdoc</documentationProvider>
            <useTags>true</useTags>
            <useBeanValidation>true</useBeanValidation>
            <performBeanValidation>true</performBeanValidation>
            <useSpringController>true</useSpringController>
            <oas3>true</oas3>
            <apiPackage>com.example.api</apiPackage>
            <modelPackage>com.example.model</modelPackage>
            <invokerPackage>com.example.invoker</invokerPackage>
            <interfaceOnly>true</interfaceOnly>
            <skipOverwrite>false</skipOverwrite>
          </configOptions>
        </configuration>
Steps to reproduce

See test in PR #14450.

Related issues/PRs
  • #14295 (closed) fixed the problem for not wrapped objects
  • #11449 might have introduced the problem
Suggest a fix

Fixed by: #14450

Assignee
Assign to
Time tracking