Skip to content

feat(tcgc): support overriding method responses - #5173

Open
iscai-msft wants to merge 12 commits into
Azure:mainfrom
iscai-msft:iscai-msft-support-response-overrides
Open

feat(tcgc): support overriding method responses#5173
iscai-msft wants to merge 12 commits into
Azure:mainfrom
iscai-msft:iscai-msft-support-response-overrides

Conversation

@iscai-msft

@iscai-msft iscai-msft commented Aug 6, 2026

Copy link
Copy Markdown
Member

fixes #3542

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8aca8827-bea2-4bf5-ae80-c87bebeedcbd
iscai-msft added 2 commits August 6, 2026 11:08
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8aca8827-bea2-4bf5-ae80-c87bebeedcbd
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8aca8827-bea2-4bf5-ae80-c87bebeedcbd
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @azure-tools/typespec-client-generator-core
Show changes

@azure-tools/typespec-client-generator-core - feature ✏️

Allow @override to replace a client method response and add the replaceResponse customization function.

@pkg-pr-new

pkg-pr-new Bot commented Aug 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/typespec-client-generator-core@5173

commit: 6e462d7

@azure-sdk-automation

Copy link
Copy Markdown
Contributor

You can try these changes here

🛝 Playground 🌐 Website

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8aca8827-bea2-4bf5-ae80-c87bebeedcbd
Comment thread .chronus/changes/replace-client-response-2026-08-06-10-49-09.md Outdated
iscai-msft and others added 3 commits August 7, 2026 12:38
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8aca8827-bea2-4bf5-ae80-c87bebeedcbd
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 8aca8827-bea2-4bf5-ae80-c87bebeedcbd
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

📦 Package size report

✅ No notable package size changes compared to the base branch.

13 package(s) with no notable change
Package Packed (base → head) Δ Packed Unpacked (base → head) Δ Unpacked
@azure-tools/typespec-client-generator-core 226.23 KB → 226.96 KB +752 B (+0.3%) 1.22 MB → 1.22 MB +4.26 KB (+0.3%)
@azure-tools/typespec-java 13.51 MB → 13.51 MB -144 B (-0.0%) 15.03 MB → 15.03 MB
@azure-tools/typespec-ts 526.37 KB → 526.37 KB -2 B (-0.0%) 2.53 MB → 2.53 MB
@azure-tools/azure-http-specs 146.21 KB → 146.21 KB 1.16 MB → 1.16 MB
@azure-tools/typespec-autorest 80.93 KB → 80.93 KB 395.06 KB → 395.06 KB
@azure-tools/typespec-autorest-canonical 7.42 KB → 7.42 KB 26.00 KB → 26.00 KB
@azure-tools/typespec-azure-core 129.41 KB → 129.41 KB 702.62 KB → 702.62 KB
@azure-tools/typespec-azure-portal-core 42.40 KB → 42.40 KB 192.87 KB → 192.87 KB
@azure-tools/typespec-azure-resource-manager 171.29 KB → 171.29 KB 1.04 MB → 1.04 MB
@azure-tools/typespec-azure-rulesets 5.16 KB → 5.16 KB 32.09 KB → 32.09 KB
@azure-tools/typespec-go 244.79 KB → 244.79 KB 1.25 MB → 1.25 MB
@azure-tools/typespec-metadata 15.91 KB → 15.91 KB 62.26 KB → 62.26 KB
@azure-tools/typespec-python 46.21 KB → 46.21 KB 180.83 KB → 180.83 KB

Packed = gzipped .tgz published to npm. Unpacked = total extracted size. 🆕 added, 🗑️ removed. Packages from the core/ submodule are not included.
🔴 grew · 🟢 shrank — only changes of at least 512 B and 0.5% are marked.

iscai-msft added 2 commits August 10, 2026 15:00
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 8aca8827-bea2-4bf5-ae80-c87bebeedcbd
iscai-msft added 3 commits August 10, 2026 15:15
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 8aca8827-bea2-4bf5-ae80-c87bebeedcbd
name: string;
}

@post op create(): Widget | Error;

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.

Java does not support union of 2 unrelated models...

Comment on lines +52 to +53
op customizedCreate(): DeleteResult;
@@override(TestService.create, TestService.customizedCreate);

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.

Why is this allowed?


const baseServiceMethod = diagnostics.pipe(
getSdkBasicServiceMethod<TServiceOperation>(context, operation, client),
getSdkBasicServiceMethod<TServiceOperation>(context, operation, client, false),

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.

Why here we pass false? This flag looks quick hacky to me.


@post op create(): Widget;

op customizedCreate(): DeleteResult;

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.

Please pay attention to the usage and serialization info of new response 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.

as well as the usage for original model.

* ```
*/
#suppress "experimental-feature" "replaceResponse uses extern fn which is experimental but provides essential response transformation functionality"
extern fn replaceResponse(operation: Reflection.Operation, response: unknown): Reflection.Operation;

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.

When we replace the response, how could we know how to map the method level response to the HTTP level response?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:java Issues for @azure-tools/typespec-java emitter lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[tcgc] do we want to allow users to @override to a different response?

4 participants