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
  • #4383
Closed
Open
Issue created Nov 05, 2019 by Jorge Rodríguez Martín@jorgerodContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [Java] Client resttemplate and webclient. Form Params are badly added when they are lists

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

Plugin will generate DefaultApi.java and when the element to be inserted to formParams is a list ... instead of an formParams.addAll it makes an formParams.add

openapi-generator version

4.1.3, 4.2.0

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: My Api
  version: 0.0.1
paths:
  /api/v1/article/id/exist:
    post:
      description: my endpoint
      operationId: checkArticle
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                articleIds:
                  description: article ids
                  type: array
                  items:
                    type: integer
                    format: int32
      responses:
        200:
          description: successful operation
          content:
            application/json:
              schema:
                type: integer
Command line used for generation

java -jar openapi-generator-cli.jar generate -g java -i openapi-rest.yml -o openapi --library resttemplate

Steps to reproduce

Run the above command.

Actual

    /**
     * 
     * my endpoint
     * <p><b>200</b> - successful operation
     * @param articleIds article ids (optional)
     * @return ResponseEntity&lt;Integer&gt;
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public ResponseEntity<Integer> checkArticleWithHttpInfo(List<Integer> articleIds) throws RestClientException {
     //...
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        if (articleIds != null)
            formParams.add("articleIds", articleIds);
     //...
   }

Expected:

    /**
     * 
     * my endpoint
     * <p><b>200</b> - successful operation
     * @param articleIds article ids (optional)
     * @return ResponseEntity&lt;Integer&gt;
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public ResponseEntity<Integer> checkArticleWithHttpInfo(List<Integer> articleIds) throws RestClientException {
     //...
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        if (articleIds != null)
            formParams.addAll("articleIds", articleIds);
     //...
   }
Related issues/PRs
Suggest a fix
Assignee
Assign to
Time tracking