[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