Skip to content

fix(http-client-python): preserve renamed body example values - #12480

Draft
Libba Lawrence (l0lawrence) wants to merge 1 commit into
microsoft:mainfrom
l0lawrence:l0lawrence-python-sample-rename-repro
Draft

Libba Lawrence (l0lawrence) wants to merge 1 commit into
microsoft:mainfrom
l0lawrence:l0lawrence-python-sample-rename-repro

Conversation

@l0lawrence

Copy link
Copy Markdown
Member

Summary

Fix Python sample generation losing REST example body values when an explicit body parameter is renamed with TCGC @clientName.

Use the body's serializedName for its code-model wireName instead of the SDK-renamed name. The SDK-facing clientName remains unchanged, and generated body parameters retain the existing "body" fallback.

For an example keyed by resource, @clientName("topic", "python") now produces:

client.create_topic(topic={"state": "Normal", "title": "Product updates"})

Previously, the sample contained placeholder "str" values.

Coverage and validation

  • Add body-name checks for explicit unrenamed, renamed, and generated body parameters.
  • Add end-to-end synchronous sample regressions asserting actual REST example values survive the rename.
  • All 17 focused tests pass; the renamed-body regressions failed before the fix.
  • Python emitter build, type-check, lint, and formatting pass.
  • Rerun the minimal control/rename reproduction: both emitted samples preserve the example values; sync and async SDK parameter names remain correct.

The generator currently emits synchronous REST samples only; no async sample coverage is claimed. Local reproduction artifacts are excluded from this PR.

Fixes #12433.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Nov 3, 2026
@pkg-pr-new

pkg-pr-new Bot commented Nov 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-python@12480

commit: 269ceb7

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/http-client-python
Show changes

@typespec/http-client-python - fix ✏️

Preserve REST example body values in generated samples when a body parameter is renamed with @clientName.

@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Python emitter diff

Baseline gh:a22c5330cea8962cd66e9ee9533f2b953e268de6 vs this PR.

No changes to generated output.

Rendered diff: inline on the run summary, or the emitter-diff-html artifact.

Informational check (eng/emitter-diff); does not block the PR.

location: bodyParam.kind,
clientName: bodyParam.isGeneratedName ? "body" : getClientName(bodyParam),
wireName: bodyParam.isGeneratedName ? "body" : bodyParam.name,
wireName: bodyParam.isGeneratedName ? "body" : bodyParam.serializedName,

@l0lawrence Libba Lawrence (l0lawrence) Nov 3, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@ body params clientNames were using bodyParam.name was the tcgc renamed value, not the name on the wire

This branch has not been deployed

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

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Python sample generation loses REST body example values when the SDK parameter is renamed

1 participant