Skip to content

Add max-overload mode to generate protocol/model WithResponse overloads for Java data-plane clients#10744

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/add-max-overloads-with-models
Draft

Add max-overload mode to generate protocol/model WithResponse overloads for Java data-plane clients#10744
Copilot wants to merge 3 commits into
mainfrom
copilot/add-max-overloads-with-models

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 20, 2026

This change adds explicit control over max WithResponse overload generation in the Java emitter/generator. It supports generating protocol (BinaryData), model, or both overload sets, while preserving Java overload legality by falling back to protocol when signatures differ only by return type.

  • Config surface

    • Added @typespec/http-client-java.max-overload emitter option with values:
      • protocol (default)
      • model
      • all
  • Generator settings + mode plumbing

    • Added MaxOverload enum and parsing in JavaSettings.
    • Exposed mode helpers (isGenerateProtocolMaxOverload, isGenerateModelMaxOverload) for mapper/template logic.
  • WithResponse overload generation behavior

    • Updated simple WithResponse mapping for data-plane clients:
      • protocol: generate protocol-style max overloads only.
      • model: generate model max overloads (using RequestOptions) and suppress public protocol overload exposure where model API exists.
      • all: generate both, except when Java signature collision would occur.
  • Collision handling for all

    • Added signature-collision filtering in convenience-method wiring:
      • If protocol/model WithResponse overloads normalize to the same public signature (name + params), model overload is dropped.
      • This preserves existing protocol behavior and avoids illegal return-type-only overloading.
  • Convenience template alignment

    • Updated convenience method templates to handle RequestOptions parameterized model max overloads (null-safe initialization when passed in vs local creation).
    • Kept protocol method invocation wiring intact across sync/async wrappers.
  • Focused test coverage updates

    • Added mapper-level tests for protocol / model / all visibility behavior.
    • Added small test-only settings helpers to configure JavaSettings modes deterministically.
"@azure-tools/typespec-java":
  flavor: azure
  max-overload: all
public Response<BinaryData> createFooWithResponse(BinaryData createFooOptions, RequestOptions requestOptions);
public Response<FooDetails> createFooWithResponse(CreateFooOptions createFooOptions, RequestOptions requestOptions);

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • archive.eclipse.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.14/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.14/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.14 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.14/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/typespec/typespec/packages/http-client-java/generator org.codehaus.plexus.classworlds.launcher.Launcher -pl http-client-generator-core spotless:apply (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:java Issue for the Java client emitter: @typespec/http-client-java label May 20, 2026
Copilot AI changed the title [WIP] Add option to generate max overloads with models Add max-overload mode to generate protocol/model WithResponse overloads for Java data-plane clients May 20, 2026
Copilot AI requested a review from srnagar May 20, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:java Issue for the Java client emitter: @typespec/http-client-java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Option to generate max overloads (WithResponse methods) with models

2 participants