fix(docs): only use user-specified displayName for undiscriminated union variants #11681
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 fern-api/fern-platform#6417
Fixes an issue where undiscriminated union variants in the API explorer displayed long generated schema names from OpenAPI (e.g., "ObjectsObjectTypeBatchUpsertPostRequestBodyContentApplicationJsonSchemaRecordsItems0") instead of user-friendly type names.
Why Undiscriminated Unions Only?
This fix targets undiscriminated unions specifically because of how
displayNameis populated differently for each union type:displayName: variant.displayName— comes directly from the IR'svariant.displayName, which is only set when the user specifiesdisplay-namein their Fern definition. No fallback tooriginalName.displayName: variant.type.displayName ?? variant.type.name.originalName— had a fallback tooriginalName, which for OpenAPI-sourced APIs could be long generated schema names.Discriminated unions are unaffected because they never had the problematic fallback behavior.
Changes Made
convertTypeShape.tsto only usedisplayNamewhen explicitly specified viadisplay-namein the Fern definitionvariant.type.name.originalNamewhich was populating displayName with generated OpenAPI schema namesundefinedfor variants without user-specified names)Testing
Human Review Checklist
undefineddisplayName correctly (usesrenderTypeShorthandas fallback, React keys useidxfallback)create-parameter-records.tshandles undefined displayName (it does - uses conditional breadcrumb)Link to Devin run: https://app.devin.ai/sessions/33185c45a6d34c6ba1a2d93478e98567
Requested by: @stephencme