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][webclient] query param of type array handled as non explode #20127

Open
5 of 6 tasks
virgilsb opened this issue Nov 18, 2024 · 0 comments · May be fixed by #20169
Open
5 of 6 tasks

[BUG][JAVA][webclient] query param of type array handled as non explode #20127

virgilsb opened this issue Nov 18, 2024 · 0 comments · May be fixed by #20169

Comments

@virgilsb
Copy link

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

Wrapping query params in a containing object so that the generated client method only has one param instead of X params, but when the query param is an array, the generated code always builds a CSV with the contents of the array, instead of handling it as "multi".

openapi-generator version

It's not a regression. Wrapping object were supported after 7.2.0 thanks to this PR but it is not working correctly when having array properties.

OpenAPI declaration file content or url
paths:
  /api/search:
    get:
      operationId: Search
      parameters:
        - name: object-param
          in: query
          required: true
          schema:
            type: object
            properties:
              someArray:
                type: array
                items:
                  type: string
  • The example is an adaptation from modules/openapi-generator/src/test/resources/3_0/java/explode-query-parameter.yaml
Generation Details

Java language, WebClient library, but also with RestTemplate.

Steps to reproduce

By adapting the upper mentioned file, execute the following test
JavaClientCodegenTest.shouldProperlyExplodeWebClientQueryParameters
adding

.bodyContainsLines("queryParams.putAll(apiClient.parameterToMultiValueMap(ApiClient.CollectionFormat.valueOf(\"multi\".toUpperCase(Locale.ROOT)), \"someArray\"," + " objectParam.getSomeArray()));");

Expected would be to handle the array query param as "multi" since explode defaults to true.
Actual: it's treated as csv because the collectionFormat param is null.

Related issues/PRs

#17441

Suggest a fix
CaptainAye added a commit to CaptainAye/openapi-generator that referenced this issue Nov 24, 2024
CaptainAye added a commit to CaptainAye/openapi-generator that referenced this issue Nov 24, 2024
CaptainAye added a commit to CaptainAye/openapi-generator that referenced this issue Nov 24, 2024
CaptainAye added a commit to CaptainAye/openapi-generator that referenced this issue Nov 24, 2024
CaptainAye added a commit to CaptainAye/openapi-generator that referenced this issue Nov 24, 2024
CaptainAye added a commit to CaptainAye/openapi-generator that referenced this issue Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant