[JAVA] Add generic okhttp client

Merged
WI
13d ago
+93157-87

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:
    ./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.

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.
  • ApiClient holds the JSON instance per client, so serializer configuration is no longer tied to a static Gson.
  • RetryingOAuth talks to OkHttp directly, dropping the Apache Oltu dependency.
  • useJspecify, useJackson3, useSingleRequestParameter, and generateInsecureTlsHook now 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 okhttp name.
  • 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-gson fixes.

Migration

  • Auth payloads passed to applyToParams change from String to byte[], and OAuth no longer depends on Oltu.