[JAVA] Add generic okhttp client
Merged
WI
13d ago+93157+93157+01234567890123456789012345678901234567890123456789-87-87-01234567890123456789
based on #24734
(trimmed samples to make the PR reviewable)
FYI @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08) @KannaKim (2026/07) @AndreyVMarkelov (2026/11)
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
(For Windows users, please run the script in WSL)./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
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.
Summary by cubic
Adds a new okhttp library to the Java client generator that supports Gson, Jackson 2, Jackson 3, and JSON-B serialization on OkHttp, forked from okhttp-gson and decoupled from it; okhttp-gson is unchanged.
Features
- A single template set under
Java/libraries/okhttp/emits clients, models, oneOf/anyOf, auth, and build files for all four serializers. ApiClientholds the JSON instance per client, so serializer configuration is no longer tied to a static Gson.RetryingOAuthtalks to OkHttp directly, dropping the Apache Oltu dependency.useJspecify,useJackson3,useSingleRequestParameter, andgenerateInsecureTlsHooknow apply to the library.- 27 sample configurations were added and wired into Maven, Gradle, sbt, and CI workflows; the user-defined-templates sample moves to the
okhttpname. - Review fixes cover gzip/progress correctness, AWS SigV4 signing, JSON-B additional properties and discriminator hierarchies, composed-model validation, and parity ports of recent
okhttp-gsonfixes.
Migration
- Auth payloads passed to
applyToParamschange fromStringtobyte[], and OAuth no longer depends on Oltu.