Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][Java][restclient,resttemplate,webclient] explode not applied to array values inside a parameter object #20126

Open
5 tasks done
wacker opened this issue Nov 18, 2024 · 0 comments

Comments

@wacker
Copy link

wacker commented Nov 18, 2024

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
@wacker wacker changed the title [BUG] Description [BUG][Java][restclient,resttemplate,webclient] explode not applied to parameter object Nov 18, 2024
@wacker wacker changed the title [BUG][Java][restclient,resttemplate,webclient] explode not applied to parameter object [BUG][Java][restclient,resttemplate,webclient] explode not applied to array values inside a parameter object Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant