Skip to content

Widgets: better oneOf schema support#38288

Open
ddadamhooper wants to merge 6 commits into
masterfrom
adam.hooper/widgets-nested-oneof
Open

Widgets: better oneOf schema support#38288
ddadamhooper wants to merge 6 commits into
masterfrom
adam.hooper/widgets-nested-oneof

Conversation

@ddadamhooper

Copy link
Copy Markdown

What does this PR do? What is the motivation?

Supports generating widget documentation once we introduce nested oneOf. See https://github.com/DataDog/datadog-api-spec/pull/5974 -- this failed build

Also: I found it hard to "see" my change in the widget list, so I scratched an itch and changed the "Option 1", "Option 2", etc. to: <type=foo> and <type=bar>. This affects a bunch of documents.

Before After
image image
image image
image image

How we find a discriminant (e.g., type or data_source):

  • In every oneOf branch, the discriminant must be a string enum
  • For every discriminant, count unique enum values: i.e., the branch has a single-value enum (a const), and no other branch has a single-value enum with the same value.
  • Pick the best discriminant. If there's no perfect match (e.g., FormulaEventsDataSource isn't unique; nor is widget type), ensure the discriminant is good -- i.e., it'll render something useful for most options.

How we render an item (e.g., <type=timeseries>):

  • If the discriminant points to a single-value enum, render that
  • Otherwise, fallback to what we have today: "Object 3", etc

Merge readiness

  • Ready for merge

For Datadog employees:

  • ⚠️ Your branch name MUST follow the <name>/<description> convention and include the forward slash (/). If you've already created your PR with an incorrect branch name, please rename your branch and open a fresh PR.
  • 🤖 New: Comment with /review to run an automated check that catches common issues before a Documentation team member reviews your PR.

AI assistance

I flipped back and forth with Opus 4.8. Most of the code is mine.

Additional notes

@ddadamhooper
ddadamhooper requested a review from a team as a code owner July 17, 2026 19:11
@datadog-prod-us1-5

This comment has been minimized.

@github-actions github-actions Bot added the Architecture Everything related to the Doc backend label Jul 17, 2026
@ddadamhooper ddadamhooper changed the title Adam.hooper/widgets nested oneof Widgets: better oneOf schema support Jul 17, 2026
@ddadamhooper

Copy link
Copy Markdown
Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Automated review by Claude. AI-generated; verify before acting.

Nice cleanup — replacing generic Option N labels with schema-derived <type=…> names should make the rendered API tables noticeably easier to navigate. A few small nits on the new helpers below; nothing blocking.

Reviewed 08c566844f3264a1df15ebbe41e57e449ef66531workflow run

Comment thread assets/scripts/build-api-pages.js Outdated
Comment thread assets/scripts/build-api-pages.js
Comment thread assets/scripts/build-api-pages.js Outdated
ddadamhooper and others added 2 commits July 17, 2026 19:33
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Architecture Everything related to the Doc backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants