Skip to content

[Java][RestClient][WebClient] refactor: use CollectionFormat helper method in query generation - #24781

Merged
wing328 merged 1 commit into
OpenAPITools:masterfrom
Mattias-Sehlstedt:utilize-collection-format-support-method
Aug 26, 2026
Merged

[Java][RestClient][WebClient] refactor: use CollectionFormat helper method in query generation#24781
wing328 merged 1 commit into
OpenAPITools:masterfrom
Mattias-Sehlstedt:utilize-collection-format-support-method

Conversation

@Mattias-Sehlstedt

Copy link
Copy Markdown
Contributor

When I previously added Json-query serialization to the RestClient and WebClient, I constructed the formatting with StringUtils.collectionToDelimitedString(values, collectionFormat.separator), this is superfluous, since CollectionFormat itself is already designed to already do exactly this with

public String collectionToString(Collection<?> collection) {
    return StringUtils.collectionToDelimitedString(collection, separator);
}

This PR changes so that the helper is properly used for the query construction.

I have also changed the CollectionFormat acccessability, since a previous PR that wanted to make everything extendable has made led to there being enum variables that are protected (which does not make sense since an enum is final).

The visibility should either be private or public, and since it a helper method that cannot be extended, I have elected to change it back to private (and that the helper method that uses the variable is public).

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 25 files

Re-trigger cubic

@wing328
wing328 merged commit 5203a01 into OpenAPITools:master Aug 26, 2026
141 checks passed
@wing328 wing328 added this to the 7.26.0 milestone Aug 26, 2026
rar91279 added a commit to rar91279/openapi-generator that referenced this pull request Sep 4, 2026
…t separator helper

Port two changes from master into the okhttp library:

- generateInsecureTlsHook (OpenAPITools#24786): when set to false, the okhttp
  ApiClient omits the verifyingSsl field, setVerifyingSsl/isVerifyingSsl
  and the trust-all X509TrustManager/HostnameVerifier, for consumers
  whose static analysis flags that code. The verifying TLS setup moves
  into trustedTrustManagers()/trustedHostnameVerifier() so both template
  variants share it.

- CollectionFormat helper (OpenAPITools#24781): deduplicate the collection-format
  delimiter lookup in parameterToPairs and collectionPathParameterToString
  into a collectionFormatSeparator method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants