Skip to content

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

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

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

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 20, 2026

  • Review new PR feedback and inspect current generated max-overload outputs
  • Identify why model-mode WithResponse returns protocol response types
  • Update generator logic/tests for correct model-mode response typing
  • Regenerate affected http-client-java generator-test outputs
  • Run targeted validation for http-client-java generator changes
  • Commit/push fixes and reply to PR comments with commit hash

@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
export interface EmitterOptions {
license?: License;
"dev-options"?: DevOptions;
"max-overload"?: "protocol" | "model" | "all";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's only support protocol or model only for now. Remove support for all.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot address the above comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. I removed support for max-overload: all and now only protocol and model are supported in the Java emitter/generator, with related all-mode logic/tests removed. Addressed in commit 4e1d885.

Copilot AI changed the title Add max-overload mode to generate protocol/model WithResponse overloads for Java data-plane clients Add max-overload mode to generate protocol or model WithResponse overloads for Java data-plane clients May 20, 2026
Copilot AI requested a review from srnagar May 20, 2026 19:28
export interface EmitterOptions {
license?: License;
"dev-options"?: DevOptions;
"max-overload"?: "protocol" | "model";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add a comment that this defaults to protocol if not set.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added the default behavior note in the emitter option description so max-overload explicitly documents defaulting to protocol when unset. Addressed in commit aef08e9. No UI changes in this PR (screenshot N/A).

description:
"Selects which max `WithResponse` overloads are generated for data-plane clients.",
nullable: true,
enum: ["protocol", "model"],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add a test spec in http-client-generator-test and update the Generate.ps1 script to run with protocol and model config to generate both variants.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added generator/http-client-generator-test/tsp/max-overload.tsp and updated generator/http-client-generator-test/Generate.ps1 to compile that spec with both max-overload=protocol and max-overload=model variants. Addressed in commit aef08e9. No UI changes in this PR (screenshot N/A).

@srnagar
Copy link
Copy Markdown
Member

srnagar commented May 20, 2026

@copilot address PR feedback

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 20, 2026

@copilot address PR feedback

Addressed the PR feedback in commit aef08e9: documented the default max-overload behavior and added generator-test spec/script coverage for both protocol and model variants. No UI changes in this PR (screenshot N/A).

Copilot AI requested a review from srnagar May 20, 2026 21:47
Comment on lines +135 to +136
"npx --no tsp compile $tspFile $tspOptions --option ""@typespec/http-client-java.max-overload=protocol"" --option ""@typespec/http-client-java.namespace=tsptest.maxoverload.protocol"" $tspTrace",
"npx --no tsp compile $tspFile $tspOptions --option ""@typespec/http-client-java.max-overload=model"" --option ""@typespec/http-client-java.namespace=tsptest.maxoverload.model"" $tspTrace"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot run this script and include the generated code in the PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ran generator/http-client-generator-test/Generate.ps1 and checked in the generated max-overload outputs for both protocol and model variants in commit 1e67e30. No UI changes in this PR (screenshot N/A).

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 20, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

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.15/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.15/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.15 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.15/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/typespec/typespec/packages/http-client-java/generator org.codehaus.plexus.classworlds.launcher.Launcher clean install --define spotless:skip --no-transfer-progress -T 1C -f ./generator/pom.xml -output/10512924rimraf ./dist ./temp ./emitter/temp ./generator/target/emitter.jar (dns block)
    • 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.15/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.15/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.15 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.15/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/typespec/typespec/packages/http-client-java/generator org.codehaus.plexus.classworlds.launcher.Launcher clean install --define spotless:skip --no-transfer-progress -T 1C -f ./generator/pom.xml n t/837677330 --trhttp-client-java (dns block)

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

Copilot AI requested a review from srnagar May 20, 2026 22:19
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<BinaryData> createWidgetWithResponse(BinaryData body, RequestOptions requestOptions) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot This should have returned Response<Widget> when max-overload: model is used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated this in commit fb1565f so the model max-overload sync method now returns Response<Widget>. No UI changes in this PR (screenshot N/A).

*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<BinaryData>> createWidgetWithResponse(BinaryData body, RequestOptions requestOptions) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot This should have returned Mono<Response<Widget>> when max-overload: model is used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated this in commit fb1565f so the model max-overload async method now returns Mono<Response<Widget>>. No UI changes in this PR (screenshot N/A).

Copilot AI requested a review from srnagar May 21, 2026 07:43
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