Skip to content

Show every method of an API operation in one joined chip - #4912

Merged
reakaleek merged 1 commit into
mainfrom
api-docs-mixed-method-lab-ba23a9f0
Nov 18, 2026
Merged

reakaleek merged 1 commit into
mainfrom
api-docs-mixed-method-lab-ba23a9f0

Conversation

@reakaleek

@reakaleek reakaleek commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

An API operation that takes several methods on one route, such as POST /_search and GET /_search, now shows one joined chip (POST|GET) on the operation page, the landing rows, both sidebars and the search route line. The "also GET" text is gone.

Affects: API reference, Site UI, Search

Prompt summary: Operations that support several methods only mention the extra ones as "also GET" on the operation page. The ask is a combined method chip that works for any combination and appears everywhere: navigation, search results, the operation page and the landing pages. The dominant method stays on the left and the others read as secondary.

Why

Only the operation page names the extra methods. The sidebar, the landing rows and search show the dominant method alone, so a reader who scans for GET never finds _search. The sidebar also builds its method without the operations collapsed onto the page, so it can disagree with the page header.

What

One chip for every method

_HttpMethodBadge takes a list of methods. One method renders exactly the markup it did before. Several methods render a pill of ordinary chips: the dominant method first, in full colour, and the others unfilled with a dashed grey outline. The chips join on a slanted edge, and a tooltip names the main method. EndpointRow.Methods and OperationEndpoint.Methods supply the list, dominant method first, then the existing rank order.

Every surface renders it

The operation page and the tag landing rows go through _EndpointPath. The product landing rows, the legacy sidebar glyph, the design-system sidebar label and the search RouteLine each render the same pill with their own sizes. Search already stored every method per route, so no reindex is needed.

The sidebar reads the navigation item

IApiOperationNavigationModel becomes IApiOperationNavigationItem, implemented by OperationNavigationItem. Its HttpMethods come from the same endpoint the page header uses, so a method from a collapsed sibling counts.

Verify

dotnet test --project tests/Elastic.ApiExplorer.Tests
dotnet test --project tests/Navigation.Tests
cd src/Elastic.Documentation.Site && npx vitest run
mise run journeys:test

./build.sh serve then open /api/doc/elasticsearch/operation/operation-search for the page and sidebar. Search needs assembler build with FEATURE_ASSEMBLER_API_EXPLORER=true against the dev index.

Check on the preview

Out of scope: OpenApiDocumentExporter builds each indexed operation without its collapsed siblings. The method listings in the spec descriptions cover the merged operations seen today, so the index already holds both methods.

🤖 Generated with Claude Code

An operation that takes GET and POST on one route now shows `POST|GET` everywhere it appears: the operation page, the landing rows, both sidebars and the search route line. The dominant method leads in full colour, and the others follow in a dashed, unfilled chip that joins it on a slanted edge. This replaces the "also GET" text on the operation page.

The sidebar reads its methods from the operation's navigation item, so a method from a collapsed sibling now counts.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@reakaleek
reakaleek requested a review from a team as a code owner November 17, 2026 21:30
@reakaleek
reakaleek requested a review from theletterf November 17, 2026 21:30
@reakaleek

Copy link
Copy Markdown
Member Author
image image

public OperationEndpoint Endpoint => field ??= OperationEndpoint.Build(Model, Model.Operation.Description, Siblings);

// The sidebar chip must list what the page header lists, including methods that come from the description's method listing or from collapsed siblings.
IReadOnlyList<string> IApiOperationNavigationItem.HttpMethods => Endpoint.Methods;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

No test covers the fix this PR is about: the sidebar now lists methods from collapsed siblings. OperationEndpointTests calls OperationEndpoint.Build(..., []) with no siblings. The nav rendering tests set HttpMethods on NavigationRenderNode by hand. OperationDeprecatedProjectionTests only checks a single-method leaf. If HttpMethods went back to building without Siblings, or CreateLeaf stopped matching IApiOperationNavigationItem, every test would still pass. Add a projection test that builds the navigation for collapsed operations (for example POST and GET /_search) and checks that the leaf's HttpMethods equals post, get.

Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.

@github-actions

Copy link
Copy Markdown
Contributor

@reakaleek
reakaleek merged commit 5cc117e into main Nov 18, 2026
50 checks passed
@reakaleek
reakaleek deleted the api-docs-mixed-method-lab-ba23a9f0 branch November 18, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant