Skip to content

[JAVA] Add generic okhttp client - #25713

Merged
wing328 merged 79 commits into
masterfrom
rar91279-java-generic-okhttp
Nov 18, 2026
Merged

wing328 merged 79 commits into
masterfrom
rar91279-java-generic-okhttp

Conversation

@wing328

@wing328 wing328 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

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.

Written for commit cddf29d. Summary will update on new commits.

View guided diff Turn on auto-fix

rar91279 and others added 30 commits August 24, 2026 10:03
…ON-B

Adds a new "okhttp" library to the Java client generator, forked from
"okhttp-gson" but decoupled from Gson: one template set emits clients for
Gson (default), Jackson 2, Jackson 3 and JSON-B, on OkHttp 5.4.0, and honours
the existing useJspecify option.

Templates (Java/libraries/okhttp/):
- JSON.mustache carries three parallel implementations - Gson (gson-fire +
  TypeAdapterFactory), Jackson (ObjectMapper, jacksonPackage-parameterised for
  2.x/3.x) and JSON-B (Yasson + JsonbAdapters, with a GenericType<T> helper
  standing in for TypeToken).
- ApiClient holds JSON as an instance so serializer config is per-client,
  passes request payloads to auth as byte[] rather than String, and signs
  AWS4 last so it sees the final query string.
- auth/RetryingOAuth embeds its own TokenRequestBuilder and talks to OkHttp
  directly, dropping the Apache Oltu dependency that okhttp-gson needs.
- api/pojo/oneof/anyof switch between TypeToken, TypeReference and
  JSON.GenericType, and use the shared nullableArgument partials plus the
  jSpecifyDatatype lambda already provided by AbstractJavaCodegen.

Templates that only differed cosmetically from their root-level counterparts
(Pair, StringUtil, ServerVariable, ServerConfiguration, maven.yml, travis,
git_push.sh) are deliberately not forked - mustache resolution falls back to
Java/ and the generated output is verified to include them.

JavaClientCodegen:
- registers the library, adds it to JSPECIFY_SUPPORTED_LIBRARIES and to the
  useJackson3 allowlist, and reuses the okhttp-gson supporting-file branch
  without forcing the serialization library.
- resolves isGson/isJackson/isJsonb after the serialization switch, where
  getSerializationLibrary() is authoritative, instead of guessing earlier.
- forces openApiNullable off for JSON-B, since jackson-databind-nullable is
  Jackson-only and the pom omits it there.
- applies the x-enum-as-string discriminator rewrite for every serialization
  library (a narrowed discriminator otherwise generates a getter that cannot
  override the parent's String getter), while keeping the JsonNullable and
  JsonIgnore imports Jackson-only.
- extends the useSingleRequestParameter and oneOf/anyOf ModelNull handling to
  the new library, both of which its templates support.
…library

bin/configs/java-okhttp-user-defined-templates.yaml generated the okhttp-gson
sample despite the neutral name; every other okhttp-gson config on master is
already named java-okhttp-gson-*. Renaming it keeps the naming consistent and
frees the java-okhttp-* prefix for the new okhttp library, without touching the
generated sample.
27 configs covering the new library: the four serialization variants (Gson,
Jackson 2, Jackson 3, JSON-B), JSpecify for each of Jackson 2/3 and JSON-B,
oneOf/anyOf, nullable-required, AWS4 signing, dynamic operations, grouped
parameters, parcelable models, streaming, swagger 1/2 annotations, OpenAPI 3.1,
the echo API and user-defined templates.

Fixes carried over from the prototype branch:
- java-okhttp-echo-api.yaml had "library" commented out, so it silently
  generated with the default okhttp-gson library instead of okhttp.
- java-okhttp-jackson-nullable-required.yaml never set
  serializationLibrary: jackson, making it a duplicate of the gson config.
- java-okhttp.yaml had "useReflectionEqualsHashCode::" with a double colon, so
  the property never applied.
- java-okhttp-jackson3-oneOf.yaml wrote to others/java/oneOf-okhttp-jackson3,
  breaking the okhttp-<serializer>-<feature> convention of its siblings, and
  java-okhttp-jackson3-jspecify.yaml reused the artifactId of the non-jspecify
  jackson3 config.
- java-okhttp-jsonb-jspecify.yaml set useJackson3 alongside JSON-B.

Every config names its serialization library explicitly, including the Gson
ones: JavaClientCodegen infers its internal "jackson" flag from the absence of
the property, so relying on the default would opt Gson output into
Jackson-specific nullable handling.

All 27 configs generate, and every generated sample compiles and passes its
tests under Maven.
- pom.xml: java-client-okhttp profile builds the four serialization variants,
  java-client-okhttp-parcelable mirrors the okhttp-gson parcelable profile.
- Workflows: each okhttp-gson entry gains its okhttp counterpart, in both the
  path triggers and the sample matrices. The petstore-server workflow gets the
  three samples that mirror okhttp-gson there; the plain client workflow gets
  the serialization, jspecify, oneOf, nullable-required, swagger, streaming,
  AWS4, grouped-parameter and parcelable samples; echo-api, gradle and sbt get
  their okhttp equivalents.
- docs/generators/java.md: regenerated - the library table gains okhttp and
  useJspecify now lists it as supported.
Generated output for the 27 new bin/configs. Every sample compiles and passes
its tests under Maven, across all four serialization variants.
The previously committed samples were generated with a jar that still contained
seven okhttp templates from an earlier prototype build: Pair, StringUtil,
ServerVariable, ServerConfiguration, maven.yml, travis and git_push.sh. Those
templates are intentionally not part of this library - mustache resolution is
supposed to fall back to the shared Java/ and _common/ templates - but stale
target/classes output survived an incremental build and was shaded into the CLI
jar, where library-local templates take precedence.

Rebuilt with `mvn clean install` and regenerated. Only git_push.sh actually
differed in the output; it now matches _common/git_push.sh.mustache and is
byte-identical to the okhttp-gson sample, as are Pair, StringUtil,
ServerVariable, ServerConfiguration, maven.yml and travis.
Correctness fixes to the forked templates:

- GzipRequestInterceptor: restore the forceContentLength() wrapper dropped from
  okhttp-gson. Without it the gzip body reports contentLength() == -1, OkHttp
  falls back to Transfer-Encoding: chunked, and every compressed request fails
  against servers that reject chunked request bodies. The unused okio.Buffer
  import was the tell that the removal was accidental.
- ProgressResponseBody: restore the memoized bufferedSource field. OkHttp calls
  source() again on close(), so without caching each call built a fresh
  ForwardingSource over a partially consumed stream, resetting the progress
  counter and risking double reads.
- ProgressRequestBody: CountingSink no longer reports done, so a known-length
  body gets exactly one terminal callback instead of two (writeTo still emits
  the terminal event, which is what unknown-length bodies rely on). Dropped the
  unreachable private countingSink(Sink) helper.
- AWS4Auth: sign x-amz-* headers. They were never added to the signable
  request, so SigV4 omitted them from SignedHeaders and AWS rejected the
  signature. Content-Type is deliberately left unsigned because OkHttp's
  BridgeInterceptor appends the multipart boundary after signing. This also
  wires up the two-pass auth ordering in ApiClient, which until now had no
  effect.
- JSON: register RFC3339JavaTimeModule for Jackson 2. The codegen already
  emitted RFC3339InstantDeserializer and RFC3339JavaTimeModule, but nothing
  installed them, so the space-separated RFC3339 normalization never ran. Every
  other Jackson library registers it. Jackson 3 does not emit the classes and
  is left untouched.
- additional_properties: replace Java `transient` with @JsonbTransient. The
  transient keyword was added by this fork and made Java serialization drop all
  undeclared properties when serializableModel=true; @JsonbTransient keeps
  JSON-B from emitting the backing map without that side effect.
- ApiResponse: lowercase header keys in the caseInsensitiveResponseHeaders
  branch, matching okhttp-gson, native, jersey2 and jersey3.
- pojo: stop emitting five Jackson imports that JavaClientCodegen already
  contributes via model.imports, which produced duplicate import lines.
  JsonTypeName is only contributed for Jackson 2, so it is still emitted from
  the template under useJackson3.

Build files:

- build.gradle: add the com.google.android:android compileOnly dependency under
  parcelableModel, mirroring the pom. Generated Parcelable models now compile
  with a plain Gradle build.
- build.sbt: add the swagger-parser-v3 dependency under dynamicOperations and
  the jakarta.validation-api dependency under useBeanValidation, both of which
  the pom and Gradle builds already declared; gate jackson-annotations on
  Jackson 2 so Jackson 3 clients take the version aligned by jackson-databind.

All 27 samples regenerated; each compiles and passes mvn test, and
JavaClientCodegenTest still passes 288 tests. okhttp-gson output is unchanged.
…imports

The previous fix emitted the JsonTypeName import from pojo.mustache whenever
useJackson3 was set. AbstractJavaCodegen already adds that import for any model
whose classname was sanitized, regardless of Jackson version, so models such as
Apple, Banana and EnumTest ended up importing it twice.

Contribute it from JavaClientCodegen.postProcessModelProperty instead. Because
model.imports is a Set, the import is emitted exactly once whichever path asks
for it, and the template no longer hardcodes it.

Jackson-annotation duplicate imports across the okhttp samples drop from 19 to
1. The remaining one is JsonIgnore on a model that hits both the
additionalProperties template path and the shared nullable addImports path,
which appends to a List without de-duplicating - the same pre-existing
mechanism that leaves five duplicate imports in okhttp-gson-nullable-required
on master.
# Conflicts:
#	modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
…t separator helper

Port two changes from master into the okhttp library:

- generateInsecureTlsHook (#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 (#24781): deduplicate the collection-format
  delimiter lookup in parameterToPairs and collectionPathParameterToString
  into a collectionFormatSeparator method.
… changes

Includes the churn from master (7.26.0-SNAPSHOT version bump, path
backslash removal, inline-enum resolver fix), the new ApiClient helpers,
and the RequiredAndNullable/FileContent files the jspecify samples were
missing since the spec gained them in #24711.
…earer-token NPE, modelCopy JsonTypeName

- JSON-B has no @JsonAnyGetter/@JsonAnySetter, so models with
  'additionalProperties: true' silently dropped undeclared fields in both
  directions. Generate a CustomJsonbSerializer/CustomJsonbDeserializer
  into each such pojo and register them in the Jsonb config built by
  JSON, mirroring what the Gson CustomTypeAdapterFactory does. Verified
  with a runtime round trip against the generated okhttp-jsonb client.

- HttpBearerAuth.getBearerToken() threw NullPointerException before a
  token was configured, although applyToParams treats an unset supplier
  as valid unauthenticated state. Return null instead.

- @JsonTypeName was emitted as "java" when pojo.mustache is rendered as
  a user-defined Model template (files config), because the bundle
  root's "name" key holds the generator name. Resolve the model name
  through the models/model scope, which works in both contexts.

- ApiResponse: use conventional 'private final' modifier order and fix
  the "response bod" javadoc typo.
Correctness fixes across the okhttp templates and JavaClientCodegen,
each verified by unit tests and runtime round trips against the
regenerated clients:

Gson:
- oneOf/anyOf branches typed List<X>/Map<String,X> had no validation
  (bare matches++), and plain non-primitive branches (UUID, BigDecimal)
  none at all, while String/Boolean accepted any primitive - valid
  payloads failed with "N classes match result, expected 1". Branch
  validation now checks the concrete JSON type, ported from the
  okhttp-gson baseline.
- Serializing a null additional property crashed on
  JsonNull.getAsJsonObject(); the baseline's isJsonNull branch is
  restored.
- JSON.isInstanceOf(type, null) returned true, letting non-nullable
  oneOf/anyOf wrappers accept null; nullable wrappers handle null in
  setActualInstance, so null now matches nothing.
- new JSON() unconditionally rebuilt the shared static Gson, discarding
  a setGson() customization on every ApiClient/RetryingOAuth
  construction; the constructor now keeps an existing instance.
- CustomTypeAdapterFactory is no longer generated for parents with
  children (it was never registered, matching the baseline guard).

Jackson:
- oneOf deserializers double-counted duplicated data types (the one
  loop missing the x-duplicated-data-type guard), so such models could
  never deserialize; jsonb loops had the same gap.
- errorObjectType's catch block gained the missing Jackson branch.
- Jackson 3 now gets RFC3339JavaTimeModule/RFC3339InstantDeserializer
  like Jackson 2 (JavaClientCodegen whitelist + JSON.mustache).
- openApiNullable is forced off for the whole library: the templates
  never emit JsonNullable, so the flag only produced dead
  equalsNullable/hashCodeNullable helpers and duplicate imports.

JSON-B:
- Discriminator hierarchies were silently unsupported (a Cat response
  typed Animal lost its fields). Yasson's native @JsonbTypeInfo cannot
  be used because the discriminator is also a bean property (key
  collision on both paths, "CHANGE naming conflict"), so hierarchy
  roots now generate TypeSelector-style custom (de)serializers that
  dispatch on the discriminator and bind subtypes through a second,
  polymorphism-free Jsonb instance (JSON.getPlainJsonb()).
- The additionalProperties deserializer coerced explicit JSON null
  into the field default, skipped readOnly properties, and read the
  volatile Jsonb once per field; it now binds null, sets readOnly
  fields reflectively, validates openapiRequiredFields (previously
  dead for JSON-B), and captures the instance once per object.
- anyOf toUrlQueryString iterated composedSchemas.oneOf and always
  returned null under supportUrlQuery.

ApiClient:
- executeStream() leaked the connection and discarded the error body
  on non-2xx responses; it now mirrors handleResponse().
- dynamicOperations sent null optional header/cookie params as empty
  strings; fillParametersFromOperation now skips null values.
- The dead public updateParamsForAuth() (stale-URI semantics diverging
  from buildRequest's inline loop) is removed.
- build.gradle no longer declares the mockito dependency pom dropped.
…oJson, free-form validation

- oneOf wrapper models were missing the static fromJson(String)/toJson()
  helpers that okhttp-gson (and this library's anyOf wrappers and plain
  pojos) expose, an API-surface regression for migrating consumers. The
  Gson block from anyof_model.mustache is mirrored into
  oneof_model.mustache.

- The per-type branch validation rejected free-form values: Object is a
  Java language-specific primitive, so an anyType branch or anyType
  container item fell into the primitive check and its "must be Number"
  fallback - a Map<String, Object> oneOf branch no longer accepted
  string/boolean/object values. anyType branches and items now skip
  validation entirely (any JSON value matches), like the okhttp-gson
  baseline.
Regenerated for the composed fromJson/toJson helpers and the anyType
validation fix.

Ports the 8 hand-maintained invoker tests from the okhttp-gson petstore
sample (ApiClient, Client, Configuration, JSON, StringUtil, ApiKeyAuth,
HttpBasicAuth, RetryingOAuth), adapted to this library: byte[] auth
payloads, the Oltu-free RetryingOAuth is exercised against a local
HttpServer instead of Mockito, JSONTest uses the composed-model
fromJson/toJson helpers and the library's fail-fast discriminator
messages, and equals() assertions avoid reflectionEquals (needs
--add-opens on JDK 9+). Suite: 501 tests, 0 failures.
…re spec, fix jsonb gaps

The three okhttp samples generated with a non-gson serializer took their spec from
3_0/java/native/petstore-...-with-http-signature.yaml, which declares an
`http_signature_test` scheme (type: http, scheme: signature). ApiClient.mustache only
registers basic/bearer/apiKey/oauth schemes, while api.mustache emits every scheme name
into localVarAuthNames, so PetApi.addPet, updatePet, findPetsByStatus and findPetsByTags
threw `RuntimeException: Authentication undefined: http_signature_test` on every generated
call surface (plain, WithHttpInfo and Async alike), with no way out: getAuthentications()
is an unmodifiable map, and the throw happens in buildRequest before any interceptor runs.

Point them at the spec java-okhttp.yaml already uses. That drops the unsatisfiable scheme
and, because all four serializers now generate from one spec, makes okhttp / okhttp-jackson
/ okhttp-jackson3 / okhttp-jsonb a like-for-like serializer matrix.

The richer spec exposed three jsonb defects, all fixed here:

* JSON.mustache registered no adapter for java.io.File, the mapping of `format: binary`.
  JSON-B then treated File as a bean: serializing recursed through getAbsoluteFile()
  ("Recursive reference has been found in class java.io.File") and deserializing demanded
  START_OBJECT where the schema carries a string. Adds a FileAdapter matching Jackson's
  representation - getAbsolutePath() out, new File(String) in.
* oneof_model/anyof_model did not import JsonbTransient, which
  additional_properties.mustache needs for its holder field. A pojo gets the import from
  pojo.mustache; a composed model got none, so any composed schema with
  additionalProperties failed to compile (40 errors).
* the composed deserializers called parser.getObject() unconditionally, which throws on
  START_ARRAY, and routed every branch through ctx.deserialize, which Yasson cannot bind to
  a root-level scalar. They now read a generic JsonValue and send structured values through
  the context and scalars through the binding API.

Verified against a Prism mock per sample, driving every generated operation of all 42
okhttp-family samples (864 operations): all four serializers are now identical
operation-for-operation on the shared spec, all 14 okhttp/okhttp-gson pairs remain
identical, and no okhttp-gson template, sample or config is touched.
…ibrary

Address the actionable findings from the 2026-09-07 review run, all confined
to the okhttp library templates:

- GzipRequestInterceptor: skip compression for AWS SigV4-signed requests.
  AWS4Auth hashes the uncompressed payload and stamps the Authorization
  header before the Request exists, so gzipping afterwards made the
  transmitted bytes disagree with the signature and AWS rejected the call.
  Guarded by withAWSV4Signature, so non-AWS clients are unchanged.
- GzipRequestInterceptor: keep upload progress truthful. Buffering to publish
  a Content-Length drained the enclosing ProgressRequestBody, firing every
  callback (terminal one included, with uncompressed totals) before a byte
  reached the socket. Compress the wrapped delegate instead and re-wrap the
  compressed buffer with the same callback, and replay it in segments so the
  upload is reported as it happens. The in-memory buffering itself is
  inherent to publishing a compressed length and is now documented.
- pojo.mustache: flatten additionalProperties for JSON-B models with
  children. @JsonbTransient hides the holder and the flattening serializer
  was registered only for non-hasChildren models, so an instance whose
  runtime type is the discriminated root silently lost its extra properties.
- build.gradle.mustache: select Java 17 when useJackson3 is set, as the POM
  already does; nothing derives the internal java17 property from it, so
  Gradle clients targeted Java 8 with a Jackson 3 dependency.
- build.sbt.mustache: add the Parcelable and Bean Validation provider
  dependencies that the POM and Gradle builds already declare.
- ProgressRequestBody: delegate isOneShot()/isDuplex() so a wrapped one-shot
  or duplex body keeps its contract.
- ApiResponse.mustache: lower-case response header names with Locale.ROOT so
  a Turkish/Azeri default locale cannot corrupt them.
- api_doc.mustache: import modelPackage rather than a non-existent
  "<invokerPackage>.models" package, so the doc examples compile.

Samples regenerated for all 27 okhttp configs. okhttp-gson stays byte
identical to master.
Jackson 3 requires Java 17, so the generated POM for a useJackson3 client
compiles with source/target 17. The three okhttp jackson3 samples were wired
into the JDK 11 sample workflow when okhttp CI coverage was added, and their
"Build with Maven" step has failed there ever since: a JDK 11 javac cannot
honour target 17.

Move them to the JDK 17 workflow, where every other library already keeps its
jackson3 sample (native-jackson3, apache-httpclient-jackson3, jersey3-jackson3):

- samples/client/petstore/java/okhttp-jackson3
- samples/client/petstore/java/okhttp-jackson3-jspecify
- samples/client/others/java/okhttp-jackson3-oneOf

The generated POMs are unchanged; only the CI wiring was wrong.
(ApiClient.java:1022-1032) — the real one. sink.writeAll(response.body().source()) never closes the body's source; on success the connection is only released because the stream happens to be read to exhaustion, but if an IOException hits mid-copy, both the BufferedSink (file descriptor) and the response body (pooled connection) leak. Needs try-with-resources on both
Close responses explicitly on failures
…ependencies

- Updated template dependencies to select Jakarta EL or Glassfish EL dynamically based on useJakartaEe (5.x for Jakarta EE and 3.x for javax).
- Adjusted hibernate-validator versions for Jakarta vs. javax compatibility.
- Flattened additionalProperties handling for JSON-B models with inheritance.
- Added branch validation in composed models to prevent mismatched deserialization.
- Ensured correct library dependencies in all build scripts (Maven, Gradle, SBT) while maintaining compatibility configurations.
…ve required-field validation

- Delegate model symbol imports to JavaClientCodegen to eliminate duplicate import lines in templates.
- Introduce `uncheckedJsonb` instance to bypass additional properties enforcement during deserialization.
- Register custom JSON-B deserializers for models with required properties for stricter validation.
- Synchronize Java version source/target settings across build tools for `useJackson3`.
82f8bfe edited build.sbt.mustache, api_doc.mustache, JavaClientCodegen.java
and the two java-okhttp-*-user-defined-templates.yaml configs, but regenerated
only the four JSON-B samples. Run the remaining 27 java-okhttp* configs so the
samples match the templates again. Generated output only, no template change:

- model imports deduplicated (JavaClientCodegen now contributes them)
- build.sbt pins -source/-target to the Maven and Gradle bytecode level
- the two user-defined-templates samples gain their README and api docs
rar91279 and others added 20 commits October 5, 2026 12:19
- ProgressRequestBody: a duplex body may keep writing after writeTo() returns, so the
  terminal onUploadProgress(done=true) is now emitted when the delegate closes the sink
  instead of when writeTo() returns (new ProgressRequestBodyTest in the okhttp sample).
- pojo: validateJsonElement(null) returns after the required-field check instead of
  falling through to getAsJsonObject() and throwing NullPointerException for models
  without required fields (JSONTest case).
- javaBuilder: the additional-properties helper is named putAdditionalProperties so it
  cannot collide with the builder setter of a declared property called
  additionalProperties (JavaClientCodegenTest case).
- pom/build.sbt: depend on com.squareup.okhttp3:okhttp-jvm. OkHttp 5 publishes
  `okhttp` as an empty Kotlin-multiplatform root artifact that only Gradle module
  metadata redirects; Maven and sbt compiled only because logging-interceptor pulls in
  okhttp-jvm transitively. build.gradle keeps `okhttp`.

Regenerated all okhttp sample configs; generator docs unchanged.
Jackson models render neither openapiFields nor the Gson/JSON-B Map.Entry
loops, so Arrays is only needed for byte[] equals/hashCode and the
JsonNullable hash helper, and Map only for the additionalProperties holder.
Drops the unused imports from the okhttp-jackson* samples.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A model with children but no discriminator (x-parent, or a single allOf
$ref) got neither the leaf (de)serializers, which skip every model with
children, nor the hierarchy-root ones, which required a discriminator. It
fell back to plain bean mapping and lost its required-field checks and
additionalProperties. The root (de)serializers now cover every parent; with
no discriminator the deserializer binds the root itself. Subtypes still
delegate to the polymorphism-free instance, so Yasson's superclass lookup
cannot narrow them to the parent. No sample defines such a parent.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…25066)

Gson's validateJsonElement and the leaf JSON-B deserializers now reject a
string property value listed in its `not: enum` (inline or $ref), so a oneOf
with complementary branches resolves to exactly one of them. Jackson is left
as is, like the other Jackson-based Java libraries.
validateJsonElement ran the `not: enum` check in the vars loop, so a child
model skipped the constraints of properties inherited from its parent while
already enforcing their required fields (openapiRequiredFields covers
allVars) and while the JSON-B deserializer checks allVars. The check now
iterates allVars, reading from jsonElement since jsonObj is only declared
for models with own vars.
# Conflicts:
#	.github/workflows/samples-java-client-echo-api-jdk8.yaml
#	.github/workflows/samples-java-client-jdk11.yaml
Regenerated the 27 java-okhttp* configs with the merged generator
(7.28.0-SNAPSHOT). Beyond the generator version string the merge changed
three things in the okhttp samples, all driven by master commits in the
shared codegen:

- api/openapi.yaml examples: empty objects are emitted as {} instead of
  the string "{}" (#25253)
- okhttp-streaming SomeObj.TypeEnum now implements Serializable under
  serializableModel (#24814)
- okhttp-3.1 api/openapi.yaml gains an `example: {}` line (#25253)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…erarchy

Port of #24895 and #25156 (okhttp-gson) to the okhttp library. With
disallowAdditionalPropertiesIfNotPresent=false every model declared its
own private Map<String, Object> additionalProperties, so an allOf child
carried the field twice and Gson refused the class before the model's
TypeAdapterFactory could run:

    IllegalArgumentException: Class Cat declares multiple JSON fields
    named 'additionalProperties'; conflict is caused by fields
    Cat#additionalProperties and Animal#additionalProperties

Every allOf child was undeserializable and unserializable in the Gson
variant of the library (verified against the petstore sample).

JavaClientCodegen now tags okhttp descendants of a model that has the bag
with x-inherits-additional-properties, and the okhttp templates render
those models like okhttp-gson does: the bag, its getters and its
equals/hashCode/toString contribution live on the topmost ancestor, the
descendant only overrides putAdditionalProperty to keep the covariant
return type. The Jackson @JsonAnySetter/@JsonAnyGetter and the JSON-B
@JsonbTransient annotations stay on the declaring class; Jackson inherits
them through the override and the generated JSON-B (de)serializers use
the inherited accessors.

Two differences from okhttp-gson: the okhttp oneOf/anyOf wrapper does
declare the bag (it keeps the properties the matched schema did not
consume), so for okhttp the ancestor walk continues through a composed
parent instead of stopping there, and a wrapper itself is never tagged
because it extends AbstractOpenApiSchema and has no super bag to call.

Tests: master's three ...ForGson tests run for okhttp-gson and okhttp;
the composed-parent expectation differs, so okhttp has its own test.
Verified with a Cat round-trip probe (deserialize, serialize, polymorphic
Animal read, equals/hashCode) on the Gson, Jackson 2 and JSON-B petstore
samples, and with the three sample test suites (512/434/436 tests).

Regenerated the 27 java-okhttp* configs: Cat, Dog and ParentPet change in
the okhttp, okhttp-jackson, okhttp-jackson3 and okhttp-jsonb petstore
samples, Cat and Dog in okhttp-3.1. No okhttp-gson file changes.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Conflict in JavaClientCodegen: master's large-oneOf tagging (#25539) and
call-local parameter renaming (#25581) land next to this branch's okhttp
additions; both sides are kept. The oneOf tagging runs before the okhttp
wrapper skip so wrappers are tagged as well.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…fixes

Ports two okhttp-gson fixes that apply to the okhttp library as well:

- #25539 (1468a35): a oneOf with more than 100 variants made the
  anonymous Gson TypeAdapter capture one local per variant, exceeding the
  JVM's 255 constructor-argument limit (ClassFormatError "Too many
  arguments in method signature"). The okhttp oneof_model.mustache now
  opens the anonymous adapter before the per-variant adapters when the
  model carries x-gson-large-oneof, exactly like okhttp-gson.
- #25581 (b665c6f): parameters named basePath, localBasePaths,
  localCustomBaseUrl or localHostIndex collide with the locals of the
  generated call methods. The okhttp api template shares those locals, so
  toParamName renames them for okhttp too.

#25542 (primitive arrays in a Gson oneOf) needs no template change: the
okhttp adapter already writes every variant through toJsonTree and the
JsonElement adapter. The test now covers okhttp to prove it.

The three master tests run for both libraries. No sample changes: the
petstore specs have neither a 100+ variant oneOf nor a colliding
parameter name.
…unused imports

ApiClient.deserialize now wraps every failure to read or parse a response
body in an ApiException that keeps the response status and headers, with
the original exception as cause. Before, a 2xx response with an unexpected
body surfaced differently per serializer: unchecked exceptions for Gson,
JSON-B and Jackson 3, and an ApiException with code 0 for Jackson 2.

Unused imports are removed from the okhttp templates, or made conditional
on the serializer and options that use them. Imports the generator adds to
every model (JsonAdapter, JsonValue, JsonCreator, SerializedName, Arrays,
List, Map, sibling models) are pruned for the okhttp library when the
rendered model does not reference them.

Only okhttp library templates and okhttp-gated generator code change;
okhttp-gson is untouched. Samples regenerated.
…t, AWS config, JDK 17 profile

- ProgressResponseBody reports done=true once; further reads of the
  exhausted source no longer repeat the completion callback.
- HttpBasicAuth encodes credentials as UTF-8, like the shared Java
  template, where Credentials.basic defaulted to ISO-8859-1.
- AWS4Auth throws ApiException when only part of credentials, region and
  service is configured, where it used to send the request unsigned.
- okhttp-jackson3 needs Java 17, so it moves to its own root pom profile
  that is activated by env=java only on JDK 17 or newer.

Samples regenerated; tests added to the okhttp petstore sample.
The comment in HttpBasicAuth claimed the other Java client libraries
encode credentials as UTF-8. Only the shared Java template does;
okhttp-gson and retrofit2 keep the ISO-8859-1 default. The comment now
says so, and that okhttp differs from okhttp-gson on purpose.

Comment only; samples regenerated.
@wing328 wing328 changed the title Rar91279 java generic okhttp [JAVA] Add generic okhttp client Nov 17, 2026
@wing328 wing328 added this to the 7.28.0 milestone Nov 17, 2026
@wing328
wing328 marked this pull request as ready for review November 17, 2026 18:20

@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.

17 issues found across 522 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/ApiClient.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/ApiClient.mustache:165">
P2: Supplying a custom `OkHttpClient` silently disables the generated download-progress interceptor. Preserve the progress interceptor when constructing the client or document and enforce the required caller configuration.</violation>

<violation number="2" location="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/ApiClient.mustache:486">
P2: Date-format configuration is global despite the per-client `json` adapter. Calling `setDateFormat` on one client changes serialization for every client; make the adapter state and setter instance-scoped.</violation>

<violation number="3" location="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/ApiClient.mustache:1252">
P2: Binary deserialization dereferences a null response body before the null-body guard. Check `response.body()` before reading bytes.</violation>

<violation number="4" location="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/ApiClient.mustache:1768">
P3: Each cookie is added as a separate `Cookie` header line. Join all cookies into one `Cookie` header with `; ` separators, since servers may read only the first header line.</violation>

<violation number="5" location="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/ApiClient.mustache:1810">
P2: Multipart form fields that are lists of non-file values are serialized incorrectly: each iteration adds the entire list instead of the current item. Pass `item` to emit one part per value.</violation>

<violation number="6" location="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/ApiClient.mustache:1963">
P2: `trustedTrustManagers()` reads `sslCaCert` as a stream every time `applySslSettings()` runs. The stream is consumed by the first call, so any later SSL setter (e.g. `setKeyManagers`, `setTlsServerName`, or `setVerifyingSsl(true)`) fails with an empty-certificate `IllegalArgumentException`. Parse the CA certificates once in `setSslCaCert` and reuse the parsed collection.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/build.sbt.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/build.sbt.mustache:85">
P2: The sbt test setup can't run the generated JUnit 5 tests. `junit-interface` only discovers JUnit 4 tests, and no Jupiter engine or bridge is declared, so the suite silently runs nothing. The Maven and Gradle builds for this library include `junit-jupiter-engine`, so this build should match them, for example by adding the sbt Jupiter bridge.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/auth/OAuth.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/auth/OAuth.mustache:15">
P2: `accessToken` is read by interceptor threads without synchronization but written under the `synchronized` `updateAccessToken`. Declare it `volatile`, as the feign, retrofit2 and jersey OAuth templates do, so refreshed tokens are visible across threads.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/javaBuilder.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/javaBuilder.mustache:34">
P2: In the `{{#parentVars}}` block, the inherited `JsonNullable` overload writes `this.instance.{{name}}` directly. The parent field is `private` unless the parent is a discriminator, so generated code for a non-discriminator allOf child will not compile. Delegate to the parent builder instead: `super.{{name}}({{name}});` followed by `return this;`.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/ProgressRequestBody.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/ProgressRequestBody.mustache:74">
P2: The duplex branch drops the `flush()` that the non-duplex path and the okhttp-gson version still run after `writeTo`. Bytes written to the wrapper buffer before `writeTo` returns stay buffered until the delegate flushes or closes, which can delay them on a duplex stream. Flush the wrapper buffer after the delegate's `writeTo` returns.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/auth/AWS4Auth.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/okhttp/auth/AWS4Auth.mustache:39">
P1: `configured` is always true because the constructor gives `credentials` a non-null default, so an unconfigured `AWS4Auth` throws on every request. Every operation's `localVarAuthNames` includes `AWS4Auth` when `withAWSV4Signature` is enabled, so clients that never call `setAWS4Configuration` fail all calls. Leave `credentials` null until `setCredentials` is called, so only partial configuration throws, as the Javadoc describes.</violation>
</file>

<file name="samples/client/petstore/java/okhttp-group-parameter/src/main/java/org/openapitools/client/ServerConfiguration.java">

<violation number="1" location="samples/client/petstore/java/okhttp-group-parameter/src/main/java/org/openapitools/client/ServerConfiguration.java:55">
P2: Server variables without an enum cause `URL(variables)` to throw a `NullPointerException`. Guard `enumValues` before checking its size.</violation>
</file>

<file name="samples/client/petstore/java/okhttp-group-parameter/git_push.sh">

<violation number="1" location="samples/client/petstore/java/okhttp-group-parameter/git_push.sh:46">
P2: This stores `GIT_TOKEN` in `.git/config` as part of the remote URL, exposing the credential to local users and tooling. Use a credential helper or pass the token only to individual Git commands.</violation>

<violation number="2" location="samples/client/petstore/java/okhttp-group-parameter/git_push.sh:54">
P3: The grep pipeline masks `git push` failures because the script returns grep’s status. Preserve and return the push exit code instead of piping it through an unchecked filter.</violation>
</file>

<file name="samples/client/petstore/java/okhttp-group-parameter/docs/Pet.md">

<violation number="1" location="samples/client/petstore/java/okhttp-group-parameter/docs/Pet.md:16">
P3: The `StatusEnum` link is broken because it targets `#StatusEnum`, while the heading generates the `#enum-statusenum` anchor. Change the link target to `#enum-statusenum`.</violation>
</file>

<file name="pom.xml">

<violation number="1" location="pom.xml:703">
P1: The `env=java` build now references generated modules that are absent from the repository, so Maven fails reactor collection before compiling the existing `okhttp` sample. Add the missing sample projects or remove their module entries.</violation>
</file>

<file name="docs/generators/java.md">

<violation number="1" location="docs/generators/java.md:69">
P3: The new `okhttp` entry leaves `useOneOfDiscriminatorLookup` documented as unsupported for okhttp, even though the okhttp oneOf/anyOf templates render that flag. Add `okhttp` to the support list in both generated Java option documents.</violation>
</file>

Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.

View guided diff | Turn on auto-fix | Re-trigger cubic

private String service;

public AWS4Auth() {
this.credentials = AnonymousCredentialsProvider.create().resolveCredentials();

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.

P1: configured is always true because the constructor gives credentials a non-null default, so an unconfigured AWS4Auth throws on every request. Every operation's localVarAuthNames includes AWS4Auth when withAWSV4Signature is enabled, so clients that never call setAWS4Configuration fail all calls. Leave credentials null until setCredentials is called, so only partial configuration throws, as the Javadoc describes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/main/resources/Java/libraries/okhttp/auth/AWS4Auth.mustache, line 39:

<comment>`configured` is always true because the constructor gives `credentials` a non-null default, so an unconfigured `AWS4Auth` throws on every request. Every operation's `localVarAuthNames` includes `AWS4Auth` when `withAWSV4Signature` is enabled, so clients that never call `setAWS4Configuration` fail all calls. Leave `credentials` null until `setCredentials` is called, so only partial configuration throws, as the Javadoc describes.</comment>

<file context>
@@ -0,0 +1,121 @@
+  private String service;
+
+  public AWS4Auth() {
+    this.credentials = AnonymousCredentialsProvider.create().resolveCredentials();
+  }
+
</file context>

Comment thread pom.xml
</activation>
<modules>
<module>samples/client/petstore/java/okhttp</module>
<module>samples/client/petstore/java/okhttp-jackson</module>

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.

P1: The env=java build now references generated modules that are absent from the repository, so Maven fails reactor collection before compiling the existing okhttp sample. Add the missing sample projects or remove their module entries.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At pom.xml, line 703:

<comment>The `env=java` build now references generated modules that are absent from the repository, so Maven fails reactor collection before compiling the existing `okhttp` sample. Add the missing sample projects or remove their module entries.</comment>

<file context>
@@ -690,6 +690,46 @@
+            </activation>
+            <modules>
+                <module>samples/client/petstore/java/okhttp</module>
+                <module>samples/client/petstore/java/okhttp-jackson</module>
+                <module>samples/client/petstore/java/okhttp-jsonb</module>
+            </modules>
</file context>

public ApiClient(OkHttpClient client) {
init();

httpClient = client;

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.

P2: Supplying a custom OkHttpClient silently disables the generated download-progress interceptor. Preserve the progress interceptor when constructing the client or document and enforce the required caller configuration.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/main/resources/Java/libraries/okhttp/ApiClient.mustache, line 165:

<comment>Supplying a custom `OkHttpClient` silently disables the generated download-progress interceptor. Preserve the progress interceptor when constructing the client or document and enforce the required caller configuration.</comment>

<file context>
@@ -0,0 +1,2104 @@
+    public ApiClient(OkHttpClient client) {
+        init();
+
+        httpClient = client;
+
+        // Setup authentications (key: authentication name, value: authentication).{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
</file context>

if (byte[].class.equals(returnType) || "byte[]".equals(returnType.toString())) {
// Handle binary response (byte array).
try {
return (T) response.body().bytes();

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.

P2: Binary deserialization dereferences a null response body before the null-body guard. Check response.body() before reading bytes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/main/resources/Java/libraries/okhttp/ApiClient.mustache, line 1252:

<comment>Binary deserialization dereferences a null response body before the null-body guard. Check `response.body()` before reading bytes.</comment>

<file context>
@@ -0,0 +1,2104 @@
+        if (byte[].class.equals(returnType) || "byte[]".equals(returnType.toString())) {
+            // Handle binary response (byte array).
+            try {
+                return (T) response.body().bytes();
+            } catch (IOException e) {
+                throw new ApiException(e.getMessage(), e, response.code(), response.headers().toMultimap());
</file context>
Suggested change
return (T) response.body().bytes();
if (response.body() == null) {
return null;
}
return (T) response.body().bytes();

* @return a {@link {{invokerPackage}}.ApiClient} object
*/
public ApiClient setDateFormat(DateFormat dateFormat) {
JSON.setDateFormat(dateFormat);

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.

P2: Date-format configuration is global despite the per-client json adapter. Calling setDateFormat on one client changes serialization for every client; make the adapter state and setter instance-scoped.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/main/resources/Java/libraries/okhttp/ApiClient.mustache, line 486:

<comment>Date-format configuration is global despite the per-client `json` adapter. Calling `setDateFormat` on one client changes serialization for every client; make the adapter state and setter instance-scoped.</comment>

<file context>
@@ -0,0 +1,2104 @@
+     * @return a {@link {{invokerPackage}}.ApiClient} object
+     */
+    public ApiClient setDateFormat(DateFormat dateFormat) {
+        JSON.setDateFormat(dateFormat);
+        return this;
+    }
</file context>

echo "[INFO] \${GIT_TOKEN} (environment variable) is not set. Using the git credential in your environment."
git remote add origin "https://${git_host}/${git_user_id}/${git_repo_id}.git"
else
git remote add origin "https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git"

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.

P2: This stores GIT_TOKEN in .git/config as part of the remote URL, exposing the credential to local users and tooling. Use a credential helper or pass the token only to individual Git commands.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/petstore/java/okhttp-group-parameter/git_push.sh, line 46:

<comment>This stores `GIT_TOKEN` in `.git/config` as part of the remote URL, exposing the credential to local users and tooling. Use a credential helper or pass the token only to individual Git commands.</comment>

<file context>
@@ -0,0 +1,54 @@
+        echo "[INFO] \${GIT_TOKEN} (environment variable) is not set. Using the git credential in your environment."
+        git remote add origin "https://${git_host}/${git_user_id}/${git_repo_id}.git"
+    else
+        git remote add origin "https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git"
+    fi
+fi
</file context>

*/
public void processCookieParams(Map<String, String> cookieParams, Request.Builder reqBuilder) {
for (Entry<String, String> param : cookieParams.entrySet()) {
reqBuilder.addHeader("Cookie", String.format(java.util.Locale.ROOT, "%s=%s", param.getKey(), param.getValue()));

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.

P3: Each cookie is added as a separate Cookie header line. Join all cookies into one Cookie header with ; separators, since servers may read only the first header line.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/main/resources/Java/libraries/okhttp/ApiClient.mustache, line 1768:

<comment>Each cookie is added as a separate `Cookie` header line. Join all cookies into one `Cookie` header with `; ` separators, since servers may read only the first header line.</comment>

<file context>
@@ -0,0 +1,2104 @@
+     */
+    public void processCookieParams(Map<String, String> cookieParams, Request.Builder reqBuilder) {
+        for (Entry<String, String> param : cookieParams.entrySet()) {
+            reqBuilder.addHeader("Cookie", String.format(java.util.Locale.ROOT, "%s=%s", param.getKey(), param.getValue()));
+        }
+        for (Entry<String, String> param : defaultCookieMap.entrySet()) {
</file context>


# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

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.

P3: The grep pipeline masks git push failures because the script returns grep’s status. Preserve and return the push exit code instead of piping it through an unchecked filter.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/petstore/java/okhttp-group-parameter/git_push.sh, line 54:

<comment>The grep pipeline masks `git push` failures because the script returns grep’s status. Preserve and return the push exit code instead of piping it through an unchecked filter.</comment>

<file context>
@@ -0,0 +1,54 @@
+
+# Pushes (Forces) the changes in the local repository up to the remote repository
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
+git push origin master 2>&1 | grep -v 'To https'
</file context>
Suggested change
git push origin master 2>&1 | grep -v 'To https'
git push origin master

|**name** | **String** | | |
|**photoUrls** | **List&lt;String&gt;** | | |
|**tags** | [**List&lt;Tag&gt;**](Tag.md) | | [optional] |
|**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] |

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.

P3: The StatusEnum link is broken because it targets #StatusEnum, while the heading generates the #enum-statusenum anchor. Change the link target to #enum-statusenum.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/petstore/java/okhttp-group-parameter/docs/Pet.md, line 16:

<comment>The `StatusEnum` link is broken because it targets `#StatusEnum`, while the heading generates the `#enum-statusenum` anchor. Change the link target to `#enum-statusenum`.</comment>

<file context>
@@ -0,0 +1,29 @@
+|**name** | **String** |  |  |
+|**photoUrls** | **List&lt;String&gt;** |  |  |
+|**tags** | [**List&lt;Tag&gt;**](Tag.md) |  |  [optional] |
+|**status** | [**StatusEnum**](#StatusEnum) | pet status in the store |  [optional] |
+
+
</file context>
Suggested change
|**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] |
|**status** | [**StatusEnum**](#enum-statusenum) | pet status in the store | [optional] |

Comment thread docs/generators/java.md
|invokerPackage|root package for generated code| |org.openapitools.client|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|library|library template (sub-template) to use|<dl><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.18.9</dd><dt>**jersey3**</dt><dd>HTTP client: Jersey client 3.1.11. JSON processing: Jackson 2.x (3.x if `useJackson3=true`, requires Java 17+)</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 13.2.1. JSON processing: Jackson 2.18.9 or Gson 2.10.1</dd><dt>**feign-hc5**</dt><dd>HTTP client: OpenFeign 13.2.1/HttpClient5 5.4.2. JSON processing: Jackson 2.18.9 or Gson 2.10.1</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1 (Retrofit 2.5.0) or Jackson 2.18.9. Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 5.3.33 (6.2.x if `useJakartaEe=true`, 7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.x (3.x if `useJackson3=true`)</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.1.18 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)</dd><dt>**restclient**</dt><dd>HTTP client: Spring RestClient 6.1.6 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 4.7.6. JSON processing: Jackson 2.18.9</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.5.2. JSON processing: Jackson 2.18.9</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 2.2.0. JSON processing: Jackson 2.18.9</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured 5.3.2 (6.x if `useJackson3=true`). JSON processing: Gson 2.10.1 or Jackson 2.18.9 (3.x if `useJackson3=true`, requires Java 17+). Only for Java 8 (Java 17+ if `useJackson3=true`)</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`). Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 2.0 (default, set desired version via `microprofileRestClientVersion=x.x.x`). JSON processing: JSON-B 1.0.2 or Jackson 2.18.9</dd><dt>**apache-httpclient**</dt><dd>HTTP client: Apache httpclient 5.2.1. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)</dd></dl>|okhttp-gson|
|library|library template (sub-template) to use|<dl><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.18.9</dd><dt>**jersey3**</dt><dd>HTTP client: Jersey client 3.1.11. JSON processing: Jackson 2.x (3.x if `useJackson3=true`, requires Java 17+)</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 13.2.1. JSON processing: Jackson 2.18.9 or Gson 2.10.1</dd><dt>**feign-hc5**</dt><dd>HTTP client: OpenFeign 13.2.1/HttpClient5 5.4.2. JSON processing: Jackson 2.18.9 or Gson 2.10.1</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**okhttp**</dt><dd>[BETA] HTTP client: OkHttp 5.4.0. JSON processing: Gson 2.10.1 (default), Jackson 2.22.1 (3.2.1 if `useJackson3=true`) or JSON-B, selected via '-DserializationLibrary'. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1 (Retrofit 2.5.0) or Jackson 2.18.9. Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 5.3.33 (6.2.x if `useJakartaEe=true`, 7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.x (3.x if `useJackson3=true`)</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.1.18 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)</dd><dt>**restclient**</dt><dd>HTTP client: Spring RestClient 6.1.6 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 4.7.6. JSON processing: Jackson 2.18.9</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.5.2. JSON processing: Jackson 2.18.9</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 2.2.0. JSON processing: Jackson 2.18.9</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured 5.3.2 (6.x if `useJackson3=true`). JSON processing: Gson 2.10.1 or Jackson 2.18.9 (3.x if `useJackson3=true`, requires Java 17+). Only for Java 8 (Java 17+ if `useJackson3=true`)</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`). Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 2.0 (default, set desired version via `microprofileRestClientVersion=x.x.x`). JSON processing: JSON-B 1.0.2 or Jackson 2.18.9</dd><dt>**apache-httpclient**</dt><dd>HTTP client: Apache httpclient 5.2.1. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)</dd></dl>|okhttp-gson|

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.

P3: The new okhttp entry leaves useOneOfDiscriminatorLookup documented as unsupported for okhttp, even though the okhttp oneOf/anyOf templates render that flag. Add okhttp to the support list in both generated Java option documents.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docs/generators/java.md, line 69:

<comment>The new `okhttp` entry leaves `useOneOfDiscriminatorLookup` documented as unsupported for okhttp, even though the okhttp oneOf/anyOf templates render that flag. Add `okhttp` to the support list in both generated Java option documents.</comment>

<file context>
@@ -66,7 +66,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
 |invokerPackage|root package for generated code| |org.openapitools.client|
 |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
-|library|library template (sub-template) to use|<dl><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.18.9</dd><dt>**jersey3**</dt><dd>HTTP client: Jersey client 3.1.11. JSON processing: Jackson 2.x (3.x if `useJackson3=true`, requires Java 17+)</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 13.2.1. JSON processing: Jackson 2.18.9 or Gson 2.10.1</dd><dt>**feign-hc5**</dt><dd>HTTP client: OpenFeign 13.2.1/HttpClient5 5.4.2. JSON processing: Jackson 2.18.9 or Gson 2.10.1</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1 (Retrofit 2.5.0) or Jackson 2.18.9. Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 5.3.33 (6.2.x if `useJakartaEe=true`, 7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.x (3.x if `useJackson3=true`)</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.1.18 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)</dd><dt>**restclient**</dt><dd>HTTP client: Spring RestClient 6.1.6 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 4.7.6. JSON processing: Jackson 2.18.9</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.5.2. JSON processing: Jackson 2.18.9</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 2.2.0. JSON processing: Jackson 2.18.9</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured 5.3.2 (6.x if `useJackson3=true`). JSON processing: Gson 2.10.1 or Jackson 2.18.9 (3.x if `useJackson3=true`, requires Java 17+). Only for Java 8 (Java 17+ if `useJackson3=true`)</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`). Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 2.0 (default, set desired version via `microprofileRestClientVersion=x.x.x`). JSON processing: JSON-B 1.0.2 or Jackson 2.18.9</dd><dt>**apache-httpclient**</dt><dd>HTTP client: Apache httpclient 5.2.1. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)</dd></dl>|okhttp-gson|
+|library|library template (sub-template) to use|<dl><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.18.9</dd><dt>**jersey3**</dt><dd>HTTP client: Jersey client 3.1.11. JSON processing: Jackson 2.x (3.x if `useJackson3=true`, requires Java 17+)</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 13.2.1. JSON processing: Jackson 2.18.9 or Gson 2.10.1</dd><dt>**feign-hc5**</dt><dd>HTTP client: OpenFeign 13.2.1/HttpClient5 5.4.2. JSON processing: Jackson 2.18.9 or Gson 2.10.1</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**okhttp**</dt><dd>[BETA] HTTP client: OkHttp 5.4.0. JSON processing: Gson 2.10.1 (default), Jackson 2.22.1 (3.2.1 if `useJackson3=true`) or JSON-B, selected via '-DserializationLibrary'. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1 (Retrofit 2.5.0) or Jackson 2.18.9. Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 5.3.33 (6.2.x if `useJakartaEe=true`, 7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.x (3.x if `useJackson3=true`)</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.1.18 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)</dd><dt>**restclient**</dt><dd>HTTP client: Spring RestClient 6.1.6 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 4.7.6. JSON processing: Jackson 2.18.9</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.5.2. JSON processing: Jackson 2.18.9</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 2.2.0. JSON processing: Jackson 2.18.9</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured 5.3.2 (6.x if `useJackson3=true`). JSON processing: Gson 2.10.1 or Jackson 2.18.9 (3.x if `useJackson3=true`, requires Java 17+). Only for Java 8 (Java 17+ if `useJackson3=true`)</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`). Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 2.0 (default, set desired version via `microprofileRestClientVersion=x.x.x`). JSON processing: JSON-B 1.0.2 or Jackson 2.18.9</dd><dt>**apache-httpclient**</dt><dd>HTTP client: Apache httpclient 5.2.1. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)</dd></dl>|okhttp-gson|
 |licenseName|The name of the license| |Unlicense|
 |licenseUrl|The URL of the license| |http://unlicense.org|
</file context>

@wing328
wing328 merged commit 6a46255 into master Nov 18, 2026
175 checks passed
@wing328
wing328 deleted the rar91279-java-generic-okhttp branch November 18, 2026 03:58
@wing328 wing328 mentioned this pull request Nov 18, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants