Repository navigation
[http-client-python] Keep REST example values for client-renamed body parameters - #12688
Open
Minh Triet Nguyen (binnguyenx) wants to merge 1 commit into
Open
Minh Triet Nguyen (binnguyenx) wants to merge 1 commit into
Minh Triet Nguyen (binnguyenx) wants to merge 1 commit into
Conversation
… parameters An explicitly named request body used TCGC's `name` as its wire name, which already includes client-only renames such as `@clientName`. Sample generation looks up REST example values by wire name, so a renamed body missed its example entry and fell back to placeholder values. Use `serializedName` instead; the SDK-facing client name is unchanged. Fixes microsoft#12433
Minh Triet Nguyen (binnguyenx)
requested review from
Chenxi Jiang (ChenxiJiang333),
catalinaperalta,
iscai-msft,
Kashif Khan (kashifkhan),
l0lawrence,
Laurent Mazuel (lmazuel),
Mark Cowlishaw (markcowl),
Yuchao Yan (msyyc),
Chenjie Shi (tadelesh),
Timothee Guerin (timotheeguerin) and
Jeff Fisher (xirzec)
as code owners
November 30, 2026 22:06
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the Python client sample-generation fix.
No open issues 🎉
What changed in this PR
Fixes #12433 by preserving REST example lookup names in the Python client emitter, so client-only body parameter renames no longer cause generated samples to use placeholders.
Changes:
- Uses
serializedNamefor explicit body wire names, preserving client-facing names and the generated"body"fallback. - Adds emitter regression coverage for renamed, unrenamed, and spread bodies.
- Adds a changelog entry describing the sample-generation fix.
| File | Description |
|---|---|
packages/http-client-python/emitter/test/emitter.test.ts |
Verifies client and wire names for three body parameter cases. |
packages/http-client-python/emitter/src/http.ts |
Preserves the REST body name for example lookup. |
.chronus/changes/python-body-rename-sample-values-2026-10-30-17-0-0.md |
Documents the Python sample-generation fix. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12433
Problem
When an explicitly named request body is renamed only for the client (for example
@body @clientName("topic") resource: Topic), generated samples use placeholder values instead of the REST example's values:emitHttpBodyParameterset the body'swireNameto TCGC'sname, which already includes the client rename.sample_serializer.pylooks up example values withself.sample_params.get(param.wire_name), and the raw example is still keyed by the REST name (resource), so the lookup missed.Fix
Use
bodyParam.serializedNamefor the body'swireName.clientNameis unchanged, and implicit (generated-name) bodies still use"body".I checked the generator for other readers of a body parameter's
wire_name: the multipart path reads the wire names of the body's entries, and the_headers/_paramspop path only handles header and query parameters. So this changes sample output only, not request serialization.Tests
clientName: "topic",wireName: "resource"), an explicit unrenamed body, and a spread body (body/body). It fails without the fix.generate-sample: trueand a REST example keyed byresource. Without the fix the sample has"str"placeholders; with the fix it has the example values.Note
#12480 took the same approach and was closed without merging or comments. If that approach was rejected for a reason, please let me know and I'll rework this.