Skip to content

[http-server-js] handle Enum type in JSON serialization transpose helpers#10059

Open
witemple-msft wants to merge 1 commit intomicrosoft:mainfrom
witemple-msft:wt/typespec/9999-bug-error-unimplemented-transformjsonexprfortype
Open

[http-server-js] handle Enum type in JSON serialization transpose helpers#10059
witemple-msft wants to merge 1 commit intomicrosoft:mainfrom
witemple-msft:wt/typespec/9999-bug-error-unimplemented-transformjsonexprfortype

Conversation

@witemple-msft
Copy link
Member

Adds case "Enum": return expr; to both transposeExpressionToJson() and transposeExpressionFromJson() in json.ts. Generated TS enums map to primitive (string/numeric) values that are directly JSON-compatible, so a no-op return is semantically correct.

Fixes #9999 — crash when a model property has an Enum type and the enclosing model requires a JSON serializer (e.g. because a property name is a reserved keyword or has a wire-name rename).

… helpers

Adds `case "Enum": return expr;` to both `transposeExpressionToJson()`
and `transposeExpressionFromJson()` in json.ts. Generated TS enums map
to primitive (string/numeric) values that are directly JSON-compatible,
so a no-op return is semantically correct.

Fixes microsoft#9999 — crash when a model property has an Enum type and the
enclosing model requires a JSON serializer (e.g. because a property
name is a reserved keyword or has a wire-name rename).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@witemple-msft witemple-msft changed the title fix(http-server-js): handle Enum type in JSON serialization transpose helpers [http-server-js] handle Enum type in JSON serialization transpose helpers Mar 17, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 17, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-server-js@10059

commit: 633da44

@github-actions
Copy link
Contributor

All changed packages have been documented.

  • @typespec/http-server-js
Show changes

@typespec/http-server-js - fix ✏️

fix: handle Enum type in JSON serialization transpose helpers to prevent crash when a model with an enum property requires a JSON serializer

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Error: Unimplemented: transformJsonExprForType: Enum

3 participants