OpenAPITools / OpenAPITools/openapi-generator
[BUG][Java][restclient,resttemplate,webclient] `explode` not applied to array values inside a parameter object
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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?
Description
explode: true does not cause array values to be exploded when given inside a parameter object, as it does using the native or apache-httpclient library.
Example: PagingParams = { sort: [ 'amount,desc', 'name,asc'] } -- a typical Pageable object in Spring Web
Generated query string using library restclient ,resttemplate or webclient:
❌ /api/search?sort=amount,desc,name,asc
Generated query string using library native or apache-httpclient:
✅ /api/search?sort=amount,desc&sort=name,asc
openapi-generator version
v7.9.0
OpenAPI declaration file content or url
openapi: 3.0.3
info: { title: API, version: 1.0.0 }
paths:
/api/search:
get:
parameters:
- in: query
name: PagingParams
schema: { $ref: '#/components/schemas/PagingParams' }
style: form
explode: true
responses:
200: { description: OK }
components:
schemas:
PagingParams:
type: object
properties:
page: { type: integer, format: int32, minimum: 0 }
size: { type: integer, format: int32, minimum: 1 }
sort: { type: array, items: { type: string } }
Generation Details
✅ generated DefaultApi.java using library native or apache-httpclient:
localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "sort", pagingParams.getSort()));
❌ generated DefaultApi.java using library restclient or webclient
queryParams.putAll(apiClient.parameterToMultiValueMap(null, "sort", pagingParams.getSort()));
❌ generated DefaultApi.java using using library resttemplate
localVarQueryParams.putAll(apiClient.parameterToMultiValueMap(null, "sort", pagingParams.getSort()));
Steps to reproduce
openapi-generator-cli generate -g java -i api-spec.yaml -o out-native --library native
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated DefaultApi.java examples and compare ApiClient.parameterToPairs with parameterToMultiValueMap for the restclient, resttemplate, and webclient libraries. Reproduce the supplied OpenAPI document with the generation command, then inspect the relevant Java generator entry points and tests. Done means array values in an exploded parameter object produce repeated sort query parameters consistently with native and apache-httpclient.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100