Skip to content

fix(typespec-go): parse text request bodies in fake servers - #5272

Open
Chenjie Shi (tadelesh) wants to merge 3 commits into
Azure:mainfrom
tadelesh:fix/go-fake-text-request-bodies
Open

fix(typespec-go): parse text request bodies in fake servers#5272
Chenjie Shi (tadelesh) wants to merge 3 commits into
Azure:mainfrom
tadelesh:fix/go-fake-text-request-bodies

Conversation

@tadelesh

@tadelesh Chenjie Shi (tadelesh) commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

  • parse generated fake-server text/plain request bodies back into their declared Go wire types
  • preserve optional zero values such as false, 0, and empty extensible-enum strings by checking request-body presence
  • reuse the existing transport scalar parser for fake text bodies without changing model, multipart, or header/query/path parsing
  • cover optional and required extensible enums plus boolean, integer, and date/time scalar bodies

Follow-up to #5238.

Validation

  • Go emitter unit suite: 42 test files, 69 tests passed
  • generated enum/scalar/date fake server compiles with go test -run '^$' ./...
  • regenerated media-type fixture compiles with go test -run '^$' ./...
  • @azure-tools/typespec-go TypeScript build
  • repository lint and formatting checks

Follow up on Azure#5238 by converting generated fake-server text bodies back to their declared Go types.

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

Copilot-Session: 291c8d49-aec6-40e7-95b7-798e6606bf2e
@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @azure-tools/typespec-go
Show changes

@azure-tools/typespec-go - fix ✏️

Parse text request bodies into their declared types in generated fake servers.

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

📦 Package size report

2 packages changed size, +2.62 KB (+0.0%) packed overall.

Package Packed (base → head) Δ Packed Unpacked (base → head) Δ Unpacked
@azure-tools/typespec-client-generator-core 227.76 KB → 229.25 KB +1.49 KB (+0.7%) 🔴 1.23 MB → 1.23 MB +3.31 KB (+0.3%)
@azure-tools/typespec-go 258.42 KB → 259.50 KB +1.08 KB (+0.4%) 1.32 MB → 1.33 MB +8.31 KB (+0.6%) 🔴
11 package(s) with no notable change
Package Packed (base → head) Δ Packed Unpacked (base → head) Δ Unpacked
@azure-tools/typespec-java 13.51 MB → 13.51 MB +33 B (+0.0%) 15.03 MB → 15.03 MB +65 B (+0.0%)
@azure-tools/typespec-python 42.20 KB → 42.22 KB +21 B (+0.0%) 164.85 KB → 164.91 KB +65 B (+0.0%)
@azure-tools/typespec-ts 527.17 KB → 527.17 KB -2 B (-0.0%) 2.54 MB → 2.54 MB
@azure-tools/typespec-azure-portal-core 42.41 KB → 42.40 KB -1 B (-0.0%) 192.91 KB → 192.91 KB
@azure-tools/azure-http-specs 146.63 KB → 146.63 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.43 KB → 129.43 KB 702.77 KB → 702.77 KB
@azure-tools/typespec-azure-resource-manager 171.92 KB → 171.92 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-metadata 15.91 KB → 15.91 KB 62.26 KB → 62.26 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.

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Go emitter diff

Baseline gh:b6b445f65578681af2d599499b16607ef1ec2d91 vs this PR.

Diff summary: 1 file(s), +2 / -1

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

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

@pkg-pr-new

pkg-pr-new Bot commented Aug 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/typespec-go@5272

commit: f3f4fb6

@azure-sdk-automation

Copy link
Copy Markdown
Contributor

You can try these changes here

🛝 Playground 🌐 Website

Reuse one scalar parser across model decoding, text responses, multipart values, fake parameters, and fake text bodies.

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

Copilot-Session: 291c8d49-aec6-40e7-95b7-798e6606bf2e
@tadelesh
Chenjie Shi (tadelesh) marked this pull request as draft August 20, 2026 10:41
Move the existing transport scalar parser into shared helpers and reuse it for fake text request bodies without broadening supported scalar types. Restore model serde and unrelated fake parameter parsing to their prior implementations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 291c8d49-aec6-40e7-95b7-798e6606bf2e
@tadelesh
Chenjie Shi (tadelesh) marked this pull request as ready for review August 21, 2026 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:go Issues for @azure-tools/typespec-go emitter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant