fix(cli): fix endpoint example generation for global headers, nullable params, and recursive types#12342
Merged
iamnamananand996 merged 7 commits intomainfrom Feb 16, 2026
Conversation
… endpoint examples Co-Authored-By: naman.anand@buildwithfern.com <iamnamananand996@gmail.com>
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. |
Traverse nullable/optional wrappers when checking for examples and generate minimal stub examples on recursive cycle detection. ExampleTypeFactory.hasExample now recurses into nullable/optional containers so examples (e.g. nullable query params) are not dropped during OpenAPI parsing. The v1 example generator (generateTypeReferenceExample) returns a minimal filled stub for named types when recursion is detected instead of failing, filling only leaf properties (primitives/enums/literals) to avoid cascade failures. Tests were updated/extended to reflect the new behavior (including a BulkSchedule-like 3-way cycle), and versions.yml was bumped with a changelog entry describing the fixes. Minor imports were adjusted to support the new helper functions.
Adjust formatting in packages/commons/ir-utils/src/examples/v1/generateTypeReferenceExample.ts: expand inline object literals into multi-line form for the alias shape and the failure return values in recursive union and undiscriminated union cases. This is a whitespace/formatting change only to improve readability; no logic was modified.
Refresh test snapshot to match new generated examples and shapes for the v3 SDK. Changes include an updated example id, expanded jsonExample values (adding left/right empty objects), and richer type/shape metadata for the TreeNode optional/container fields (including empty jsonExample placeholders and named type details). This is a snapshot-only update under packages/cli/api-importers/v3-importer-tests/src/__test__/__snapshots__/v3-sdks/example-depth.json.
Co-Authored-By: naman.anand@buildwithfern.com <iamnamananand996@gmail.com>
fern-support
approved these changes
Feb 16, 2026
…ailure Co-Authored-By: naman.anand@buildwithfern.com <iamnamananand996@gmail.com>
Co-Authored-By: naman.anand@buildwithfern.com <iamnamananand996@gmail.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.
Description
Refs: Devin session
Requested by: @iamnamananand996
Three related fixes for endpoint example generation in the OpenAPI importer and IR generator:
1. Global header example failure drops all endpoint examples
When a global header's schema cannot produce an example (e.g.
literal<2025-09-18>without quotes),ExampleEndpointFactory.buildEndpointExamplereturned an empty array for every endpoint, causing alluserSpecifiedExamplesto be dropped from the IR. Reported via polytomic/polytomic-python#9 — regression introduced in CLI v0.64.23 (2194f78).2.
hasExample()ignores nullable/optional wrappersExampleTypeFactory.hasExample()did not recurse intonullableoroptionalwrappers, silently dropping params that had examples inside those wrappers.3. Recursive types cause cascading example failures
When cycle detection triggered in
generateTypeReferenceExample(v1), it returnedfailure, which cascaded up and killed the entire parent example. Now generates minimal stub examples with leaf (primitive/enum/literal) properties filled in, so parent examples survive.Changes Made
ExampleEndpointFactory.ts: Removed thereturn []early-exit when a global header example is null. The header is gracefully skipped instead — matching existing behavior for non-required regular headers.ExampleTypeFactory.ts: Addednullableandoptionalcases tohasExample()that recurse into the wrapped schema.generateTypeReferenceExample.ts: Replaced cycle-detectionfailurereturn withgenerateMinimalNamedExample()— a new function (~200 lines) that produces stub examples for objects (leaf properties only), enums (first value), aliases (resolve or empty object), and unions (first no-properties variant). Undiscriminated unions still return failure.generateTypeReferenceExample.test.ts: Updated existing cycle tests to expect stubs instead of failures; added newBulkSchedule-like 3-way cycle test case.example-depth.json(stubleft: {}, right: {}at cycle boundary) andsimple-fhir.json(recursive FHIR types now produce stubs instead of empty examples).versions.yml: Single consolidated changelog entry for CLI v3.78.1.Testing
git diff --exit-codeCI check passes (snapshots committed)Review Checklist
generateMinimalNamedExampleedge cases: The new stub generator handles objects, enums, aliases, and unions. Verify the logic for each branch, especially:isLeafTypeReferenceintentionally returnsfalsefor lists/maps/sets — recursive containers get skipped in stubsundiscriminatedUnionreturns failure (could still cascade in some schemas)maxDepth: 3andskipOptionalProperties: truefor leaf property generation within stubssimple-fhir.jsondiff is massive (~17M chars). Spot-check a few recursive types (e.g.,Patient,Account,Script) to verify stubs look reasonable.this.logger.trace(...)for debuggability.