Skip to content

Replace js-yaml with yaml and lodash with built-ins in http-client-java#11134

Draft
XiaofeiCao wants to merge 6 commits into
microsoft:mainfrom
XiaofeiCao:xiaofeicao/http-client-java-replace-js-yaml-lodash
Draft

Replace js-yaml with yaml and lodash with built-ins in http-client-java#11134
XiaofeiCao wants to merge 6 commits into
microsoft:mainfrom
XiaofeiCao:xiaofeicao/http-client-java-replace-js-yaml-lodash

Conversation

@XiaofeiCao

@XiaofeiCao XiaofeiCao commented Jul 1, 2026

Copy link
Copy Markdown
Member

Changes

  • js-yaml -> yaml: emitter/src/emitter.ts now uses yaml's stringify() instead of js-yaml's dump() to serialize code-model.yaml. yaml is already present transitively in the repo, and its version (^2.8.3) is aligned with the pnpm-workspace.yaml catalog.
  • lodash -> built-in: emitter/src/code-model-builder.ts replaces the single lodash.isEqual call (comparing two string[] api-version arrays) with a built-in length + element-wise === comparison.
  • Dropped js-yaml, lodash, @types/js-yaml, @types/lodash from package.json; added yaml. Refreshed package-lock.json.

Compatibility

code-model.yaml is parsed by the Java code-model deserializer, which relies on YAML anchors/aliases to reconstruct shared object identity. Verified that yaml.stringify emits &a1/*a1 anchors/aliases for shared references, matching js-yaml.dump behavior.

Validation

  • npm run build:emitter (tsc)
  • npm run test:emitter (19 tests pass)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:java Issue for the Java client emitter: @typespec/http-client-java label Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http-client-java
Show changes

@typespec/http-client-java - internal ✏️

Replace js-yaml with yaml for code-model serialization and drop lodash in favor of a built-in array comparison.

@azure-sdk-automation

azure-sdk-automation Bot commented Jul 1, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

XiaofeiCao and others added 2 commits July 2, 2026 09:03
Regenerate lock from upstream base and restore Linux-only @emnapi optional deps that npm install on Windows had pruned, fixing npm ci EUSAGE in CI.

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

@weidongxu-microsoft weidongxu-microsoft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok for me as long as Regen works

XiaofeiCao and others added 3 commits July 3, 2026 10:18
The yaml package defaults to YAML 1.2 core schema, which has no timestamp type and emits date-like api-version strings (e.g. 2025-01-02) unquoted. The Java generator's SnakeYAML parser (YAML 1.1) then interprets them as Date, breaking generated code. Passing { version: '1.1' } quotes such strings, matching the previous js-yaml.dump behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Explain that SnakeYAML (the Java generator's consumer) is a YAML 1.1 parser, so the emitter must serialize with { version: '1.1' } to keep date-like and other 1.1-implicit values quoted.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:java Issue for the Java client emitter: @typespec/http-client-java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants