fix(cli): unescape dollar-prefixed object keys in jsonExample#12521
Open
fix(cli): unescape dollar-prefixed object keys in jsonExample#12521
Conversation
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
🌱 Seed Test SelectorSelect languages to run seed tests for:
How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR. |
…dollar-ref-key-escaping
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.
Description
Refs: Reported by @jsklan
When an OpenAPI spec contains
$ref(or any$-prefixed key) as a literal object key inside an example (not as a JSON reference), the Fern CLI correctly escapes it to\$refin the Fern definition to avoid collision with the$example reference prefix. However, when converting back from Fern definition → IR, the backslash was not stripped from object keys in thejsonExamplefield — only from string values. This caused downstream generators (e.g. Go) to emit invalid code like"\$ref".Link to Devin run | Requested by: @jsklan
Changes Made
ExampleResolver.ts: Added key unescaping inresolveAllReferencesInExamplewhen iterating object entries. Keys starting with\$are stripped of the leading backslash, matching the existing unescaping logic already applied to string values (lines 45–49 in the same method).versions.yml: Added changelog entry for CLI v3.79.3.Testing
Human Review Checklist
$-prefixed keys roundtripping through OpenAPI → Fern def → IRconvertObjectinconvertExampleType.tslooks up typed properties by wire key — if the key is still\$refat that point, it won't match a property named$ref. This is a separate concern not addressed here.