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

[BUG][JAVA] request body parameter with explode=true need to generate separate parameters for each value of the array

Created by: ynojima

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
openapi: "3.0.0"
info:
  version: 1.0.0
  title: Example API
paths:
  /translate:
    post:
      operationId: translate
      summary: Translate text
      requestBody:
        content:
          application/x-www-form-urlencoded:
            encoding:
              text:
                explode: true
                style: form
            schema:
              type: object
              properties:
                text:
                  type: array
                  items:
                    type: string
      responses:
        '200':
          description: translations
        default:
          description: error

The code generated from the above spec should yield following request. expected request(values form separate parameters:

curl -X 'POST' \
  'https://example.com/translate' \
  -H 'accept: */*' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'text=string&text=string'

actual request (values are joined into one parameter):

curl -X 'POST' \
  'https://example.com/translate' \
  -H 'accept: */*' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'text=string,string'

Please refer OAS v3 Encoding object section for more details: https://swagger.io/specification/

openapi-generator version

5.3.1

OpenAPI declaration file content or url

See the example above.

Generation Details

Java API client generation

Steps to reproduce

Generate Java API client from the aboe spec, and send a request with that and check the request body of it.

Related issues/PRs

None

Suggest a fix

at least api.mustache template need to be fixed: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/api.mustache#L98

Assignee
Assign to
Time tracking