Replace js-yaml with yaml and lodash with built-ins in http-client-java#11134
Draft
XiaofeiCao wants to merge 6 commits into
Draft
Replace js-yaml with yaml and lodash with built-ins in http-client-java#11134XiaofeiCao wants to merge 6 commits into
XiaofeiCao wants to merge 6 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
…ent-java-replace-js-yaml-lodash
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
approved these changes
Jul 3, 2026
weidongxu-microsoft
left a comment
Contributor
There was a problem hiding this comment.
ok for me as long as Regen works
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>
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.
Replace two small dependencies in the
@typespec/http-client-javaemitter with lighter alternatives.Changes
emitter/src/emitter.tsnow usesyaml'sstringify()instead ofjs-yaml'sdump()to serializecode-model.yaml.yamlis already present transitively in the repo, and its version (^2.8.3) is aligned with thepnpm-workspace.yamlcatalog.emitter/src/code-model-builder.tsreplaces the singlelodash.isEqualcall (comparing twostring[]api-version arrays) with a built-inlength+ element-wise===comparison.js-yaml,lodash,@types/js-yaml,@types/lodashfrompackage.json; addedyaml. Refreshedpackage-lock.json.Compatibility
code-model.yamlis parsed by the Java code-model deserializer, which relies on YAML anchors/aliases to reconstruct shared object identity. Verified thatyaml.stringifyemits&a1/*a1anchors/aliases for shared references, matchingjs-yaml.dumpbehavior.Validation
npm run build:emitter(tsc)npm run test:emitter(19 tests pass)