OpenAPITools / OpenAPITools/openapi-generator

[REQ] Feature Request Description

Open
#9,359 0 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

In environment: JAVA-SPRING generation via maven plugin.
Trying to use add parameter of Map<String,String> to a multipart/form-data contenttype

Description

The yaml part underneath fails, and I get the - [ERROR] Map of form parameters not supported. Please report the issue to https://github.com/openapitools/openapi-generator if you need help. So I did.

What I want to create is a endpoint like this.:

default ResponseEntity uploadFile(@ApiParam(value = "") @Valid @RequestPart(value = "filelist", required = false) List filelist,@ApiParam(value = "") @Valid @RequestPart(value = "tags", required = false) Map<String, String>> tags) {
return getDelegate().uploadFile(filelist, tags);
}
}

But the yaml generation fails.

openapi-generator version

5.1.0

OpenAPI declaration file content or url
MAP of Form not supported:
  /upload:
    post:
      tags:
        - data-upload
      summary: Upload file for processing
      operationId: uploadFile
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                filelist:
                  type: array
                  items:
                    type: string
                    format: binary
                tags:                                 #Object that fails
                  type: object
                  additionalProperties:
                    type: string
Generation Details
            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>5.1.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>
                                ${project.basedir}/src/main/resources/openapi.yml
                            </inputSpec>
                            <generatorName>spring</generatorName>
                            <apiPackage>no.di.didataimport.api</apiPackage>
                            <modelPackage>no.di.didataimport.model</modelPackage>
                            <generateAliasAsModel>true</generateAliasAsModel>
                            <supportingFilesToGenerate>
                                ApiUtil.java
                            </supportingFilesToGenerate>
                            <configOptions>
                                <delegatePattern>true</delegatePattern>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
Steps to reproduce

Same yaml endpoint with version 5.1.0

To info

With the following yaml, the Map is successfully wrapped inside a list. List<Map<String, String>>

      content:
          multipart/form-data:
            schema:
              type: object
              properties:
                filelist:
                  type: array
                  items:
                    type: string
                    format: binary
                tags:
                  type: array
                  items:
                    type: string
                    additionalProperties:
                      type: string

Describe the solution you'd like

Support for Map of form parameteres.

Describe alternatives you've considered

Scrapping the codegeneration and go code first :(.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Java Spring generator's multipart/form-data handling and reproduce the failure using the provided OpenAPI YAML and Maven plugin configuration. Support an object with additionalProperties of type string as a Map form parameter, then verify that generation produces the requested filelist and tags method signature without the unsupported-map error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
api, backend, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.