Skip to content

[API explorer] Replace raw x-state badges with applies_to popover#3026

Open
szabosteve wants to merge 3 commits intomainfrom
szabosteve/api-exp-exp
Open

[API explorer] Replace raw x-state badges with applies_to popover#3026
szabosteve wants to merge 3 commits intomainfrom
szabosteve/api-exp-exp

Conversation

@szabosteve
Copy link
Copy Markdown
Contributor

@szabosteve szabosteve commented Apr 2, 2026

Summary

Relates to https://github.com/elastic/docs-eng-team/issues/452

  • Replace raw x-state string badges (<span class="version-badge">) with structured <applies-to-popover> web component badges on API explorer endpoint pages
  • Parse x-state into lifecycle (GA, Preview, Beta, Deprecated, Removed) and version data using the same logic as OpenApiDocumentExporter
  • Badges now render consistently with the rest of the documentation site

Changes

  • New: AvailabilityBadgeHelper.cs -- parses x-state extensions and produces badge attributes for the <applies-to-popover> web component
  • Edit: OperationView.cshtml -- replaced version-badge span with applies-to-popover below the h1 title; removed leftover debug spans
  • Edit: _PropertyItem.cshtml -- same badge treatment for property-level x-state annotations
  • Edit: _UnionOptions.cshtml -- propagates VersionsConfiguration to child contexts
  • Edit: RenderContext.cs -- added optional VersionsConfiguration property to PropertyRenderContext and UnionVariantsContext

Notes

  • Serverless badges are not shown because the OpenAPI specs contain no serverless availability data in x-state
  • Popover detail panel is disabled (show-popover="false") -- can be enabled as a follow-up
  • No new project dependencies added; the helper is self-contained in Elastic.ApiExplorer

Made with Cursor

Parse x-state extension values into structured lifecycle and version
data, then render them using the existing applies-to-popover web
component instead of plain version-badge spans. This makes endpoint
availability badges consistent with the rest of the documentation site.

Made-with: Cursor
@szabosteve szabosteve requested a review from a team as a code owner April 2, 2026 14:01
@szabosteve szabosteve requested a review from reakaleek April 2, 2026 14:01
@szabosteve szabosteve requested a review from Mpdreamz April 2, 2026 14:02
@coderabbitai coderabbitai bot added the feature label Apr 2, 2026
@szabosteve szabosteve changed the title API explorer: Replace raw x-state badges with applies_to popover [API explorer] Replace raw x-state badges with applies_to popover Apr 2, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d005a629-942f-4197-9291-596712b13054

📥 Commits

Reviewing files that changed from the base of the PR and between 72fdb2c and e155b8b.

📒 Files selected for processing (1)
  • src/Elastic.ApiExplorer/Operations/AvailabilityBadgeHelper.cs

📝 Walkthrough

Walkthrough

This change adds an AvailabilityBadgeHelper and AvailabilityBadgeData to parse x-state from OpenAPI operations and schemas, derive product lifecycle and semantic version info, and produce structured badge data (or null). Rendering contexts (PropertyRenderContext, UnionVariantsContext) gain an optional VersionsConfiguration property propagated into nested renders. Razor views and partials call the helper (passing VersionsConfiguration) and render an applies-to-popover when badge data is returned, replacing prior inline x-state parsing.

Sequence Diagram(s)

sequenceDiagram
    participant View as Operation/Property View
    participant OpenApi as OpenApiOperation/Schema
    participant Versions as VersionsConfiguration
    participant Helper as AvailabilityBadgeHelper
    participant Popover as applies-to-popover

    View->>OpenApi: pass operation/schema
    View->>Versions: provide VersionsConfiguration
    View->>Helper: FromOperation/FromSchema(OpenApi, Versions)
    Helper->>OpenApi: read "x-state" extension
    Helper->>Helper: parse lifecycle and extract semantic version
    Helper->>Versions: consult version lookup (released/unreleased)
    Helper-->>View: AvailabilityBadgeData (or null)
    alt badge data present
        View->>Popover: render with BadgeKey, LifecycleText, Version, Flags
    else no badge
        View-->>View: skip popover rendering
    end
Loading

Suggested labels

feature, enhancement

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: replacing raw x-state badges with applies_to popover components in the API explorer.
Description check ✅ Passed The description is well-structured, relates directly to the changeset, explains the motivation, lists affected files, and notes important implementation details like disabled popovers and no new dependencies.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch szabosteve/api-exp-exp

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Elastic.ApiExplorer/Operations/AvailabilityBadgeHelper.cs`:
- Around line 83-103: GetCurrentStackVersion(versionsConfig) can return null and
current code treats that as "not released" causing all badges to show planned;
change the isReleased logic so a null currentVersion does not force "planned" —
set isReleased = currentVersion is null || version.Min <= currentVersion (or
equivalent) in the AvailabilityBadgeHelper flow so parsed lifecycle/version
(FormatVersion/versionDisplay, ProductLifecycle handling and the '+' TrimEnd)
are used when no stack config is available.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 724b49f4-1733-443d-9a38-018a4a843ba4

📥 Commits

Reviewing files that changed from the base of the PR and between b9765e5 and 72fdb2c.

📒 Files selected for processing (5)
  • src/Elastic.ApiExplorer/Operations/AvailabilityBadgeHelper.cs
  • src/Elastic.ApiExplorer/Operations/OperationView.cshtml
  • src/Elastic.ApiExplorer/Schema/RenderContext.cs
  • src/Elastic.ApiExplorer/Shared/_PropertyItem.cshtml
  • src/Elastic.ApiExplorer/Shared/_UnionOptions.cshtml

Comment thread src/Elastic.ApiExplorer/Operations/AvailabilityBadgeHelper.cs
Comment thread src/Elastic.ApiExplorer/Operations/AvailabilityBadgeHelper.cs
Broaden version regex from "Added in X.Y.Z" to any semver pattern so
deprecated/removed versions are also captured. Treat missing stack
version config as released rather than planned, so badges fall back
to the parsed lifecycle/version instead of mislabeling as "Planned".

Made-with: Cursor
@szabosteve szabosteve requested a review from lcawl April 15, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant