Skip to content

Explain API authentication once and badge each endpoint with it - #4634

Merged
akira28 merged 12 commits into
mainfrom
feature/api-authentication-page
Oct 29, 2026
Merged

akira28 merged 12 commits into
mainfrom
feature/api-authentication-page

Conversation

@akira28

@akira28 akira28 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

API endpoint pages no longer repeat the same Authentication section. A shared Authentication page, listed under Topics, holds the tabs, and each endpoint gets an Auth badge that links to it.

Affects: API reference

Prompt summary: Reactivate the spec-generated Authentication page. Show an endpoint's own authentication only when it differs from the spec's default, and add a badge before the availability badge that points to the page. Prose from children: and x-topics behaves the same and renders above the tabs.

Why

No spec in the assembled set (Elasticsearch, Kibana, Cloud, Logstash) overrides the document-level security on any operation, so every endpoint shows the same block. The generated /authentication page is hidden and nothing links to it. The cloud spec declares an apiKey scheme but no security, so its endpoints say nothing about authentication.

What

Authentication page

/authentication is built for every spec with security schemes and listed first under Topics, followed by Rate limiting, ahead of any other children: pages and topics. It builds its tabs from the document-level security, or one tab per scheme when there is none. The tabs show open, under the page's own title, with no collapsible heading. A single scheme still gets its tab, because nothing else on the page names it. An x-topics entry titled Authentication, or a children: page whose first heading is Authentication, renders above the tabs. A child page takes the place of the generated page in the sidebar, and the generated page stays hidden for old links.

Page titles

The topic and Authentication pages put their title in the same api-page-intro header as operation pages, with the same type size and a smaller gap under the breadcrumb. A children: page keeps its H1 in its own Markdown, so its first heading takes the same style through a class on its section. This applies to every children: page.

Endpoint section and badge

An endpoint shows its own Authentication section only when its security names other alternatives than the document's. An Auth badge sits before the availability badge. Both it and Deprecated render with the availability badge's own classes, in the default and design-system looks, so they keep its size and outline. Deprecated keeps a red cue, and a badge that links is underlined. It links to the page, or to the endpoint's own section when it overrides the default. Auth optional marks an anonymous alternative, and No auth marks security: [] with no link. The CommonMark output gets an Authentication: line.

Tests and docs

A new api-explorer-document-security.json fixture covers inherited, repeated, narrowed, optional and empty security. docs/data/openapi/api-explorer.md describes the page, the badge table and the rule for the endpoint section.

Out of scope: in the design-system look, the availability badge is a <button> that renders at 16px text and 43.6px tall, larger than the 12px badge in the design. The new badges follow the design, so they are smaller than it there. That gets fixed separately. The page-level TOC of a children: page is unchanged, and this PR does not move any x-topics content to children:.

Verify

dotnet test tests/Elastic.ApiExplorer.Tests/
# DocumentSecurityRenderingTests covers each badge variant and the page
cd src/Elastic.Documentation.Site && npm run visual:seed && npm run visual:check

Check on the preview

  • Elasticsearch v9: Get a behavioral analytics collection — an Auth badge before the availability badge, no Authentication section, and the badge links to the Authentication page.
  • Elasticsearch v9: Get index template (legacy) — the badge row under the path: an outlined Auth badge (underlined, since it links), then a Deprecated badge with a red outline and red text, then the availability badge. All three share the outlined look.
  • Logstash v9: Node info JVM — Auth optional, because the spec allows an anonymous alternative. It links to the Authentication page, which says "Authentication is optional" above the Basic tab.
  • Kibana v9: API overview — a children: page: its title uses the same size and gap under the breadcrumb as the operation pages above.
  • Elasticsearch v9: Authentication — Api key, Basic and Bearer tabs, listed under Topics.
  • Cloud: Authentication — the single-scheme example: the x-topics Authentication text first, then one open "Api key" tab with Authorization: <value>, and no second Authentication title. This spec has no document-level security, so the tab comes from components.securitySchemes.
  • Kibana v9: Authentication — control page: two tabs, and the Kibana spaces topic still sits next to it.

Endpoint pages repeated the same Authentication section, because no spec overrides the document-level `security`. The Authentication page now holds the tabs and sits under Topics. Endpoints show an `auth` badge that links to it, and keep their own section only when their `security` differs. A `children:` page or an `x-topics` entry titled Authentication renders above the tabs.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@akira28
akira28 requested a review from a team as a code owner October 29, 2026 10:27
@akira28
akira28 requested a review from Mpdreamz October 29, 2026 10:27
Override detection now counts the anonymous alternative, so `{}` added or dropped makes an endpoint keep its own section. The badge finds the Authentication page from endpoints under a tag-group classification. The shared section opens on topic, structural and Markdown pages, where the click handler ignored `#elastic-docs-v3`. The CommonMark writer for the section is shared, and the badge kind is an enum.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The Authentication page and a child Authentication page reused the endpoint's collapsible section, so they repeated the title and started closed. They now render the tabs directly. The endpoint keeps its collapsible section.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

… page

With one scheme the page showed a bare code block and never named it. The page has no section heading to carry the label, so it now always shows the tab strip, as the child pages do. Endpoint sections keep skipping the tab for a single scheme.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The titles sat in a bare section, so they used the Markdown heading size and padding. They now share the `api-page-intro` header of operation pages, with the same type size and a smaller gap under the breadcrumb.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
A `children:` page keeps its H1 in its own Markdown, so it kept the Markdown heading size and padding. Its section now has a class, and the first heading takes the title style of operation and topic pages.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The badges under the path were filled pills that did not match the applicable-info badge beside them. They now share its outlined look in both the default and design-system styles, Deprecated keeps a red cue, and a linking badge is underlined. Their text is capitalised.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…y badge

The badges inherited the page line height, so they were about 2px taller than the availability badge next to them. They now use the leading of its text.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The badges under the path had their own CSS, so their size drifted from the availability badge next to them. They now render with its classes in both looks, and only the red tone and the link style are set here. The design-system look is not checked against its availability badge, which renders larger than the design.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
They sat on the text baseline while the availability badge sits on the bottom of its line, so the row's badges were 1.4px apart vertically. They now share its alignment.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
With a children: page, as on Kibana, the Authentication page sat after it. It now leads the Topics heading whether it comes from the spec, a topic or a children: page, and the children: pages keep their declared order after it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The two pinned topics now lead the heading wherever they come from, including a children: page, which stands for the one its first heading or covered topic names. The other children: pages follow in declared order, then the spec's other topics by title.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@akira28
akira28 merged commit 4dc76d8 into main Oct 29, 2026
36 checks passed
@akira28
akira28 deleted the feature/api-authentication-page branch October 29, 2026 15:02
reakaleek added a commit that referenced this pull request Nov 23, 2026
* Show each API authentication method under its own heading

The Authentication page put its methods in tabs, so a reader saw one at a time and could not link to one. Each method is now an `h2` with the anchor it had before #4634, listed in "On this page" and in the Markdown export. Endpoint pages keep their tabs. Headings under the smaller API page title now step down to 24px, and the API "On this page" list renders the same `_PageToc` partial as the docs, so it uses the docs type and shows the current section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: describe the Authentication page headings in the API Explorer docs (per review by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Render API authentication sections as docs headings with Bump.sh anchors

The sections were hand-built `h2` elements, so their headings were not linkable and their anchors (`#apikeyauth`) did not match the links readers already have from the Bump.sh portal (`#doc-authentication-api-key-auth`). The page now writes the sections as Markdown and renders them with its own prose, so each heading is a docs heading with a link, a hover anchor and an entry in "On this page". The anchors match Bump.sh, and the `.md` output comes from the same Markdown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: say the Authentication page lists the document-level alternatives (per review by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: render each authentication fragment on its own (per review by @infra-vault-gh-plugin-prod)

A scheme description with an unclosed fence could swallow the credential and every later section, because the page rendered them as one Markdown document.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: render the child Authentication page's spec sections on the API description path (per review by @infra-vault-gh-plugin-prod)

Appending them to the page's Markdown sent spec descriptions through the docs parser, which shows their HTML, such as `<br>`, as text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: test that Authentication headings keep their Bump.sh anchors in the rail and the HTML (per review by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Build the Authentication sections from the document in one place

The Authentication page and a child page that stands for it each read the requirements, built the sections and rendered them, and an `anchors` flag kept the Bump.sh anchors out of the `.md` output. Both pages now render through one helper that takes the document, and the API `.md` output drops heading anchors itself, as docs pages do, which also covers anchors written in topic and child-page prose. Generated Markdown renders as one fragment, and only spec descriptions render on their own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Show an Authorization API key behind the ApiKey word

The credential example said `Authorization: <value>`, while the curl samples and every Elastic API send `Authorization: ApiKey <key>`. The Authentication page and the endpoint tabs now show `Authorization: ApiKey <api-key>`. An API key in any other header keeps `<value>`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Style the On this page links once, on the shared list

The API rail copied the docs sidebar link rule into `.api-rail-toc .sidebar-link`, because it sits outside the docs `.sidebar`. The shared `_PageToc` list now carries a `page-toc` class, and one `.page-toc .sidebar-link` rule in `styles.css` styles its links on docs and API pages. Each layout keeps hiding its own rail: docs from 1280px (lg), API from 1024px, where each puts the rail beside the article.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Say what api-rail-toc does on the API rail

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: say the Authentication page falls back to the declared schemes (per review by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: say an endpoint with security: [] shows no Authentication section (per review by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: close a fenced block only on a matching fence when stripping heading anchors (per review by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: check the generated Authentication page renders its sections and no tabs (per review by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: test that an unclosed fence in a scheme description stays in its own fragment (per review by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor: match the docs parser's heading anchor when writing API .md (simplify pass)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Leave heading anchors out of the Authentication .md instead of stripping them

The `.md` output of every API page stripped a trailing `[anchor]` from headings, only so the Authentication sections needed no flag. That took a fence scanner and a copy of the docs parser's anchor pattern, and changed authored prose on pages this change is not about. `AuthenticationFragments` takes `anchors` again, and `ApiCommonMark` is back to what main has. A test stub that mostly checked its own output and an unrelated `ToTocItem` helper go too.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

---------

Co-authored-by: Jan Calanog <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants