Repository navigation
Show each API authentication method as a linkable docs section - #4996
Conversation
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]>
| @if (Model.Authentication is { } authentication) | ||
| { | ||
| @(await RenderPartialAsync<_AuthenticationTabs, AuthenticationSectionModel>(authentication)) | ||
| @(await RenderPartialAsync<_AuthenticationHeadings, AuthenticationSectionModel>(authentication)) |
There was a problem hiding this comment.
Severity: P2 (Medium)
Authentication pages supplied through children: render the new headings but never add them to the page TOC. Readers still cannot jump to authentication methods from the rail on these pages; populate the TOC and reserve the generated anchors when rendering the child Markdown, as on the structural page.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
This is substantial enough to track separately. Created #4998 as a follow-up. A children: page has no right rail for any of its headings, not just the authentication ones, because MarkdownPageView defines no rail and the renderer returns no headings for that Markdown. Adding one changes every children: page. Not blocking this PR.
There was a problem hiding this comment.
Agreed—the finding was too narrowly framed as an authentication-only gap. MarkdownPageViewModel inherits the base GetTocItems() implementation, which returns an empty list, while MarkdownPageView renders the authentication headings without adding TOC entries. That supports the broader children:-page issue you describe; I’ll treat the auth headings as one example rather than a separate rail-specific defect. (MarkdownPageViewModel, ApiViewModel.GetTocItems, MarkdownPageView)
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
| public string Label => string.Join(" + ", Schemes.Select(static s => s.Label)); | ||
|
|
||
| /// <summary>The heading anchor on the Authentication page: the scheme ids, so a link to one alternative stays stable.</summary> | ||
| public string Slug => string.Join("-", Schemes.Select(static s => s.Id)).ToLowerInvariant(); |
There was a problem hiding this comment.
Severity: P3 (Low)
Slug lowercases the scheme ids and joins them with -, so different alternatives can end up with the same slug. Alternatives keeps them apart on purpose: it dedupes case-sensitively and uses a unit separator so {a, b} and "a-b" stay distinct. When two slugs collide, the Authentication page renders two h2s with the same id, and the "On this page" entries and #… links all go to the first one. Consider making the slug unique, for example by adding a suffix on collision, or by escaping the separator.
Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
No change for now. The slug is deliberately the anchor the page had before #4634 (id.ToLowerInvariant()), so links like /authentication#apikeyauth land again, and a suffix scheme would change it. A collision needs two securitySchemes keys that differ only by case, or a key containing - that matches another alternative's joined ids. The pre-#4634 page carried the same risk and no spec we publish has such keys. If one shows up, the fix is to add a suffix to the second id at the page level, and the first anchor stays the same.
There was a problem hiding this comment.
Correction to my reply above: the anchor I kept was this repo's own preview anchor, not one readers have. The live page is the Bump.sh portal, and its links use #doc-authentication-api-key-auth. Fixed in 3e072ec. The sections now render as docs Markdown with explicit anchors from ApiUrlBuilder.AuthenticationAnchor: doc-authentication- and the scheme id in kebab case, the same as Bump.sh. A collision would now need two scheme ids that kebab to the same text, such as apiKey and api_key. No API on the local build has that (checked all 10), and Bump.sh would have produced the same clash.
…cs (per review by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4996/ Sample changed pages: |
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]>
…s (per review by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nfra-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]>
| Open the section to see one tab per scheme. A tab shows the header or query parameter to send, for example `Authorization: Basic <credentials>`, and the scheme `description`. One scheme shows no tabs. A search with the browser's find-in-page opens the section and selects the tab that contains the match. | ||
|
|
||
| The `/authentication` page is generated for every spec that declares security schemes, and the sidebar lists it right after the **Overview** row. It shows the same tabs as an endpoint's section, so the Markdown below also applies there. The tabs are always open, under the page's own title, without the collapsible **Authentication** heading. Any prose comes first: an `x-topics` entry titled `Authentication` renders above the tabs, and so does a [`children:`](#api-children) page whose first heading is `Authentication`. When a child page stands for Authentication, it takes the place of the generated page in the sidebar and the badge links to it. The generated `/authentication` page stays for old links. Refer to [Topic pages](#x-topics). | ||
| The `/authentication` page is generated for every spec that declares security schemes, and the sidebar lists it right after the **Overview** row. It lists the document-level alternatives, the ones every endpoint without its own `security` accepts, each under a heading of its own, for example **Api key**, **Basic** and **Bearer**. An endpoint that sets a different `security` shows its own **Authentication** section instead, and its `Auth` badge links there, so a credential on this page might not work for that endpoint. The sections render like the rest of the page's Markdown, so each heading is a linkable docs heading listed in **On this page**. A heading's anchor is the one Bump.sh used: `doc-authentication-` and the scheme id in kebab case, so `apiKeyAuth` is `#doc-authentication-api-key-auth`. An alternative with several schemes joins their ids. Each section shows the scheme `description`, then the credential to send. Any prose comes first: an `x-topics` entry titled `Authentication` renders above the headings, and so does a [`children:`](#api-children) page whose first heading is `Authentication`. When a child page stands for Authentication, it takes the place of the generated page in the sidebar and the badge links to it. The generated `/authentication` page stays for old links. Refer to [Topic pages](#x-topics). |
There was a problem hiding this comment.
Severity: P3 (Low)
The Authentication page does not always list alternatives inherited by endpoints. When top-level security is absent or empty, the page lists the schemes declared in components.securitySchemes instead. Call out that fallback so readers don’t mistake a scheme listed on the page for one the spec says every endpoint accepts.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
Fixed in 33831da. The passage now says that when the document sets no security, the page lists one alternative per scheme in components.securitySchemes, which the spec declares but does not say an endpoint accepts.
| Open the section to see one tab per scheme. A tab shows the header or query parameter to send, for example `Authorization: Basic <credentials>`, and the scheme `description`. One scheme shows no tabs. A search with the browser's find-in-page opens the section and selects the tab that contains the match. | ||
|
|
||
| The `/authentication` page is generated for every spec that declares security schemes, and the sidebar lists it right after the **Overview** row. It shows the same tabs as an endpoint's section, so the Markdown below also applies there. The tabs are always open, under the page's own title, without the collapsible **Authentication** heading. Any prose comes first: an `x-topics` entry titled `Authentication` renders above the tabs, and so does a [`children:`](#api-children) page whose first heading is `Authentication`. When a child page stands for Authentication, it takes the place of the generated page in the sidebar and the badge links to it. The generated `/authentication` page stays for old links. Refer to [Topic pages](#x-topics). | ||
| The `/authentication` page is generated for every spec that declares security schemes, and the sidebar lists it right after the **Overview** row. It lists the document-level alternatives, the ones every endpoint without its own `security` accepts, each under a heading of its own, for example **Api key**, **Basic** and **Bearer**. An endpoint that sets a different `security` shows its own **Authentication** section instead, and its `Auth` badge links there, so a credential on this page might not work for that endpoint. The sections render like the rest of the page's Markdown, so each heading is a linkable docs heading listed in **On this page**. A heading's anchor is the one Bump.sh used: `doc-authentication-` and the scheme id in kebab case, so `apiKeyAuth` is `#doc-authentication-api-key-auth`. An alternative with several schemes joins their ids. Each section shows the scheme `description`, then the credential to send. Any prose comes first: an `x-topics` entry titled `Authentication` renders above the headings, and so does a [`children:`](#api-children) page whose first heading is `Authentication`. When a child page stands for Authentication, it takes the place of the generated page in the sidebar and the badge links to it. The generated `/authentication` page stays for old links. Refer to [Topic pages](#x-topics). |
There was a problem hiding this comment.
Severity: P3 (Low)
The new override sentence promises a local Authentication section and badge link even for security: []. That override opts out of authentication: the endpoint shows an unlinked No auth badge and no section. Qualify the sentence so it doesn’t contradict the behavior described just above.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
Fixed in 202c56d. The override sentence now applies to a different, non-empty security. A new sentence says an endpoint with security: [] needs no credential, so it shows no section and an unlinked No auth badge, matching the badge table above.
…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]>
…the rail and the HTML (per review by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Opus 5.5 <[email protected]>
| var headings = new List<TocItem>(); | ||
| foreach (var fragment in fragments.Where(static f => !string.IsNullOrWhiteSpace(f))) | ||
| { | ||
| var (fragmentHtml, fragmentHeadings) = RenderWithHeadings(context, fragment); |
There was a problem hiding this comment.
Severity: P3 (Low)
This strips the first H1 from every fragment, not just the page title. If the intro has # Authentication and a scheme description has # Obtaining a key, both disappear from the HTML and the ToC even though the second is content. Keep the title-stripping behavior for the intro, but preserve headings in scheme fragments.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
No change. Every spec description in the API Explorer renders on its own through RenderApiDescription, which drops a leading H1 as a title. That includes the same scheme description in an endpoint's Authentication tab, and operation and schema descriptions. Rendering each description as its own fragment makes the Authentication page behave the same way. Before the split, the page dropped only the first H1 of the whole text, so it handled a description differently depending on its position. A description H1 would also sit under the section's h2, which breaks the outline whether or not it is kept.
| foreach (var scheme in requirement.Schemes) | ||
| { | ||
| if (together) | ||
| yield return Fragment(m => ApiCommonMark.Heading(m, 3, scheme.Label)); |
There was a problem hiding this comment.
Severity: P3 (Low)
A scheme description that starts with a Markdown horizontal rule can lose its opening prose. Once the description is parsed by itself, a leading --- and a later --- are read as YAML front matter rather than visible separators. Parse scheme descriptions as content fragments without front-matter handling.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
No change. A description that opens with --- reads as front matter wherever the API Explorer renders it, because every description goes through RenderApiDescription on its own, the same scheme's endpoint tab included. Rendering the Authentication page's descriptions as fragments only brings that page in line. Turning off front matter for descriptions would change every API page, so it doesn't belong in this PR.
| { | ||
| var item = fixture.Walk().OfType<StructuralNavigationItem>().Single(n => n.Model.Kind == ApiStructuralKind.Authentication); | ||
|
|
||
| var page = StructuralViewModel.Create(item.Model, RenderContext(item, renderer: AnchoredHeadingRenderer.Instance)); |
There was a problem hiding this comment.
Severity: P3 (Low)
This test would still find every heading if the generated page went back to parsing one Markdown string: the fake renderer treats heading-looking lines inside code fences as headings. Add a case with an unclosed fence in the first scheme description, using the real API Markdown renderer, and verify that the credential example and the next scheme's anchor and ToC entry still render.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
Fixed in dced317, partly as asked. Elastic.ApiExplorer.Tests cannot load the real Markdown renderer, because it has no DocumentationSet, and Elastic.Markdown.Tests does not reference the API Explorer. Isolation comes from where the fragments split, so AuthenticationFragments_DescriptionWithAnUnclosedFence_StaysInItsOwnFragment builds a spec whose first scheme description opens a fence and never closes it. It pins that the description is a fragment of its own and that the credential and the next scheme's anchored heading come after it. RenderAsync_ChildTitledAuthentication_RendersTheSpecSectionsOnTheApiDescriptionPath covers the other half: each fragment reaches the renderer in a separate call, through the same StructuralViewModel.RenderAuthentication the generated page uses.
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]>
| if (trimmed.StartsWith(fence, StringComparison.Ordinal)) | ||
| fence = null; | ||
| } | ||
| else if (trimmed.StartsWith("```", StringComparison.Ordinal) || trimmed.StartsWith("~~~", StringComparison.Ordinal)) | ||
| fence = trimmed[..3]; |
There was a problem hiding this comment.
Severity: P3 (Low)
The fence scanner can edit code examples in the Markdown export. It remembers only the first three fence characters, so an inner three-backtick line ends a four-backtick block for the scanner, and the next bracketed code line gets treated as a heading.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
Fixed in 8007183. The scanner now keeps the whole opening run, and closes the block only on a run of the same character that is at least as long, with nothing after it, as CommonMark does. StripHeadingAnchors_LongerFenceHoldingAShorterOne_KeepsTheWholeBlock covers a four-backtick block that holds a three-backtick line, and fails with the old scanner.
There was a problem hiding this comment.
Update: 6fedabd removes StripHeadingAnchors and its fence scanner, so this code is gone. See the thread on Prepared.
| public static void Prepared(StringBuilder markdown, string? source, string apiBaseUrl) | ||
| { | ||
| var prepared = ApiMarkdown.Prepare(source, apiBaseUrl); | ||
| var prepared = StripHeadingAnchors(ApiMarkdown.Prepare(source, apiBaseUrl)); |
There was a problem hiding this comment.
Severity: P3 (Low)
Stripping bracket suffixes in the shared Prepared helper breaks valid reference-style heading links in exported Markdown. For example, ## Configure [API keys][keys] loses [keys] even on an endpoint page, where no authentication anchor was generated. Omit the generated anchors when writing the auth headings instead of stripping brackets from authored Markdown.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
No change. The docs parser already reads that trailing [keys] as the heading's anchor: HeadingAnchorParser.MatchAnchor matches \[[^[]+\]\s*$ on the heading line. So the HTML page shows the heading "Configure [API keys]" with the id keys, and no link. ReadApiDescriptionHeadings_ReferenceLinkAtTheEnd_ReadsItsLabelAsTheAnchor in Elastic.Markdown.Tests checks this on the real pipeline. Stripping in the .md output keeps it matching the page, as the docs pages' .md does. 00abb4a makes the API regex the parser's own pattern, so both drop exactly the same text.
There was a problem hiding this comment.
Update: taken as suggested after all, in 6fedabd. ApiCommonMark.Prepared is back to what main has, and AuthenticationFragments leaves the generated anchors out of the .md output with an anchors flag. Authored headings in .md are untouched again.
| authentication.Should().Contain("Use an API key."); | ||
| // The page shows its sections open, under its own title, with no collapsible Authentication heading. | ||
| authentication.Should().NotContain("api-param-section-toggle"); |
There was a problem hiding this comment.
Severity: P3 (Low)
This change drops the only end-to-end check that the generated /authentication page renders its sections. The page now has to contain only the intro prose and no section toggle, so it would still pass if StructuralView stopped printing BodyHtml (for example, if ShowEmptyMessage or the view's else if branch regressed). It would also pass if the tabs came back. AuthenticationPage_KeepsEachHeadingLinkableAndListsItInTheRail only checks the view model, not the rendered page. Add back an assertion on a section heading or anchor in the rendered page, and one that tabs-label is absent.
Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
Fixed in 291311e. The generated page test asserts the rendered page holds the Api key section with its doc-authentication-api-key anchor and has no tabs-label and no section toggle. Dropping BodyHtml from StructuralView makes it fail.
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]>
The API rail now renders the shared `_PageToc` list inside main's `api-rail-toc` nav, which keeps `data-toc` for the design system scroll spy and the rail's own link size. The shared list adds `data-toc-link`. The heading step-down rule keeps main's Endpoints headings and this branch's topic, Authentication and children: pages. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…per review by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n (per review by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ding anchors (per review by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… no tabs (per review by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… own fragment (per review by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… (simplify pass) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing 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]>
The API Authentication page now lists each way to authenticate as a regular docs section, not in tabs. Each heading links with the anchor the Bump.sh portal used, so links people already have still land on the right method. Its headings sit below the page title in size, and its "On this page" list matches the docs.
Affects: API reference, Site UI
Prompt summary: Replace the tabs on the API
/authenticationpages with one heading per authentication method, as the page looked before tabs. Then fix the type on that page: the headings were bigger than the title, and "On this page" was bigger than on regular docs pages. After comparing with the live Bump.sh page, make the sections behave like a regular docs page, with linkable headings and the anchors readers already use.Why
The Authentication page shows its methods as tabs, so a reader sees one at a time, the methods are missing from "On this page", and no link can point to one of them. Links into the live Bump.sh portal use anchors such as
#doc-authentication-api-key-auth, which the new page never sets, and a CDN redirect cannot fix that because browsers keep the#part to themselves. The API page title is 30px, but bodyh2headings keep the 36px Markdown size, so they render bigger than the title. The API "On this page" list is a separate copy of the docs list, and its current-section border never shows, because it waits for.currentwhiletoc-nav.tssetstoc-current.What
Authentication sections are docs Markdown
OperationCommonMark.AuthenticationFragmentswrites the document-level alternatives as Markdown: a##heading each, then each scheme's description and anhttpblock with the credential to send.StructuralViewModel.RenderAuthenticationrenders them on the API description path after the page'sx-topicsprose, so the headings get the docs heading markup: a link, the hover#, and an entry in "On this page". Achildren:page that stands for Authentication appends the same HTML after its own Markdown. Each spec description renders as a fragment of its own, so an unclosed fence or raw HTML in it cannot change the sections after it. Endpoint pages keep their collapsible tabs.The credential matches the curl samples
An API key in the
Authorizationheader now shows asAuthorization: ApiKey <api-key>, the form the curl samples send and Elastic APIs expect, instead ofAuthorization: <value>. This also changes the endpoint tabs. An API key in any other header keeps<value>..mdoutputThe
.mdoutput writes the same sections with plain##headings: the Bump.sh anchor is only added for the HTML page.Bump.sh anchors
Each heading sets its anchor explicitly, with
ApiUrlBuilder.AuthenticationAnchor:doc-authentication-and the scheme id in kebab case, soapiKeyAuthis#doc-authentication-api-key-authandapiKeyis#doc-authentication-api-key. An alternative with several schemes joins their ids.Headings step down under the API title
The rule that already makes landing and group headings smaller than the page title now covers topic, Authentication and
children:pages too. Theirh2headings are 24px and theirh3headings 20px.One "On this page" list for docs and API pages
The list moves into a shared
_PageTocpartial inElastic.Documentation.Site/Layout/, which both_TableOfContentsand_ApiTocrender. One.page-toc .sidebar-linkrule instyles.cssstyles its links on both, replacing the copy of the docs rule the API rail had inapi-docs.css. The current-section border waits fortoc-current, the classtoc-nav.tssets, where the API copy waited for.currentand never showed it. Each layout still hides its own rail where it sits under the article: docs from 1280px (lg), API from 1024px. The API nav keepsapi-rail-tocanddata-tocfor the design system bundle, and each link carriesdata-toc-link.Verify
Open
http://localhost:3000/api/elasticsearch/authentication, then/api/elasticsearch/authentication#doc-authentication-basic-auth.Check on the preview
#, listed in "On this page" at the docs size.Out of scope: the step-down rule still lists each API page type. One shared class on every API article body would replace that list, but it touches the landing and group views. A
children:page has no "On this page" rail at all, tracked in #4998.🤖 Generated with Claude Code