Skip to content

fix(api-type-document): suppress main-example section for Nil types @W-23748889 - #99

Open
alexpmule wants to merge 1 commit into
mainfrom
W-23748889/nil-shape-main-example
Open

fix(api-type-document): suppress main-example section for Nil types @W-23748889#99
alexpmule wants to merge 1 commit into
mainfrom
W-23748889/nil-shape-main-example

Conversation

@alexpmule

Copy link
Copy Markdown
Contributor

What

Suppress the standalone main-example section for Nil-typed properties.

Why

set _hasExamples only treated ScalarShape as scalar-like when deciding whether to render the standalone main example, whereas _typeChanged already treats ScalarShape and NilShape alike. AMF 5.11.x now materializes an example: null as a concrete Example node, so Nil types started rendering a spurious (empty) main-example block.

How

  • Add _isScalarLikeType(type)ScalarShape || NilShape, mirroring _typeChanged.
  • Use it in both set _hasExamples and set noMainExample so Nil types suppress the main-example section, matching existing scalar behavior.

Verification

Patched the installed copy of this component (4.2.43) inside the API Console v6 worktree with these exact changes and ran the full console unit suite (Node 18, Playwright/Chromium):

  • test/api-console-documentation.test.js (contains the Nil type cases): 115 passing, 0 failed.
  • Full console suite: 469 passing, 0 failed, 2 skipped.

Without the fix, the Nil-type cases fail because the empty .examples section is rendered instead of hidden.

Version bumped 4.2.43 → 4.2.44 so CI publishes the new release on merge.

@W-23748889

🤖 Generated with Claude Code

@salesforce-cla

Copy link
Copy Markdown

Thanks for the contribution! Unfortunately we can't verify the commit author(s): Alex Perez <a***@s***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, refresh the status of this Pull Request.

…lable-union types

The standalone main-example section was rendered (empty) for Nil-typed
properties. `set _hasExamples` derived `scalarType` from ScalarShape only,
while `_typeChanged` already treats ScalarShape, NilShape, and nullable
unions (`type | null`) alike. AMF 5.11.x now materializes an `example: null`
as a concrete Example node, so those types began rendering a spurious block.

Introduce `_isScalarLikeType` covering ScalarShape, NilShape, and nullable
unions (via `_checkNullableUnion`), operating on the resolved type for parity
with `_typeChanged`, and use it in both `set _hasExamples` and
`set noMainExample`. Nullable unions are the dominant OAS 3.1/3.2 shape, so
their coverage is required, not incidental.

Add generator-independent regression tests (inline AMF nodes) locking Nil,
nullable-union, and positive-control behavior, plus direct `_isScalarLikeType`
unit tests. Fix a vacuous existing assertion that queried a nonexistent
`examples` tag instead of `.examples`.

@W-23748889
@alexpmule
alexpmule force-pushed the W-23748889/nil-shape-main-example branch from 14adf87 to aae3d54 Compare August 16, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant