Add max-overload mode to generate protocol or model WithResponse overloads for Java data-plane clients#10744
Add max-overload mode to generate protocol or model WithResponse overloads for Java data-plane clients#10744Copilot wants to merge 7 commits into
max-overload mode to generate protocol or model WithResponse overloads for Java data-plane clients#10744Conversation
…hods Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/aee86c1c-fc77-4e89-93e8-a148c5d49443 Co-authored-by: srnagar <51379715+srnagar@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/aee86c1c-fc77-4e89-93e8-a148c5d49443 Co-authored-by: srnagar <51379715+srnagar@users.noreply.github.com>
max-overload mode to generate protocol/model WithResponse overloads for Java data-plane clients
| export interface EmitterOptions { | ||
| license?: License; | ||
| "dev-options"?: DevOptions; | ||
| "max-overload"?: "protocol" | "model" | "all"; |
There was a problem hiding this comment.
Let's only support protocol or model only for now. Remove support for all.
There was a problem hiding this comment.
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.
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/b1794428-b7da-4a7c-bb62-831f79584f2c Co-authored-by: srnagar <51379715+srnagar@users.noreply.github.com>
max-overload mode to generate protocol/model WithResponse overloads for Java data-plane clientsmax-overload mode to generate protocol or model WithResponse overloads for Java data-plane clients
| export interface EmitterOptions { | ||
| license?: License; | ||
| "dev-options"?: DevOptions; | ||
| "max-overload"?: "protocol" | "model"; |
There was a problem hiding this comment.
Add a comment that this defaults to protocol if not set.
There was a problem hiding this comment.
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"], |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
|
@copilot address PR feedback |
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/1a6bac46-b926-4622-8aa3-564c280f9ce1 Co-authored-by: srnagar <51379715+srnagar@users.noreply.github.com>
| "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" |
There was a problem hiding this comment.
@copilot run this script and include the generated code in the PR.
There was a problem hiding this comment.
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).
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/811619f6-9770-4590-bbff-a632e211d8a6 Co-authored-by: srnagar <51379715+srnagar@users.noreply.github.com>
|
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:
If you need me to access, download, or install something from one of these locations, you can either:
|
| */ | ||
| @Generated | ||
| @ServiceMethod(returns = ReturnType.SINGLE) | ||
| public Response<BinaryData> createWidgetWithResponse(BinaryData body, RequestOptions requestOptions) { |
There was a problem hiding this comment.
@copilot This should have returned Response<Widget> when max-overload: model is used.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
@copilot This should have returned Mono<Response<Widget>> when max-overload: model is used.
There was a problem hiding this comment.
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).
…ponse Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/48392fa5-7032-4b09-bc91-47f9a7453ac8 Co-authored-by: srnagar <51379715+srnagar@users.noreply.github.com>
WithResponsereturns protocol response types