Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b85e3c6
Lift API Explorer page work off Findability onto main
itsalexcm Aug 31, 2026
c69f4d7
Keep supplemental API catalog wiring after the rebase
itsalexcm Sep 1, 2026
ead9a99
Put API version and examples pickers in the nav-select chrome
itsalexcm Sep 3, 2026
52cf546
Paint API type chips and collapse parameter lists
itsalexcm Sep 4, 2026
5c258c3
Keep the isolated API fixture key unique
itsalexcm Sep 4, 2026
897065b
Link API type names and keep property name anchors
itsalexcm Sep 8, 2026
d3b086c
Collapse multi-item API sections including Authorization
itsalexcm Sep 8, 2026
89af5eb
Match nested property toggles to the Response disclosure
itsalexcm Sep 8, 2026
3f4fb34
Register extra Isolated API fixtures in the local docset
itsalexcm Sep 8, 2026
046084f
Merge origin/main into feat/api-explorer-improvements
itsalexcm Sep 8, 2026
896cc36
Show API union variants and a collapsible Responses list
itsalexcm Sep 21, 2026
de9b5a1
Merge origin/main into feat/api-explorer-improvements
itsalexcm Sep 21, 2026
f3ca79e
Put API copy, language, and example controls on the page chrome
itsalexcm Sep 22, 2026
08871f3
Merge origin/main into feat/api-explorer-improvements
itsalexcm Sep 22, 2026
93c27ec
Drop the duplicated BuildType initializer after merging main
itsalexcm Sep 22, 2026
6775a62
Restore collection expressions the merge rewrote to constructors
itsalexcm Sep 22, 2026
107bf43
Keep API version and search fixed in the sidebar
itsalexcm Sep 22, 2026
2c000f8
Merge origin/main into feat/api-explorer-improvements
reakaleek Sep 22, 2026
1965b64
fix: keep one diagnostics poll loop (per review by @github-actions)
reakaleek Sep 22, 2026
1b8a47f
fix: wait out a slow diagnostics poll (per review by @github-actions)
reakaleek Sep 22, 2026
a94cf3d
fix: render legacy headings as text (per review by @github-actions)
reakaleek Sep 22, 2026
0fa8ec3
Merge origin/main into feat/api-explorer-improvements
reakaleek Sep 22, 2026
4db88ca
Merge origin/main into feat/api-explorer-improvements
reakaleek Sep 22, 2026
eabc037
Label API versions latest, v9, and v8
reakaleek Sep 22, 2026
451b7ef
Merge origin/main into feat/api-explorer-improvements
reakaleek Sep 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions docs/data/openapi/api-explorer.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ The following slugs are reserved and cannot be used as child file names:
| Reserved slug | Reason |
|---|---|
| `types` | API Explorer uses this path for schema type pages |
| `tags` | API Explorer uses this path for tag landing pages |
| `group` | Tag landing pages use `/group/` |
| `operation` | Operation pages use `/operation/` |
| `authentication` | Reserved for API Explorer and cannot be used as a child file slug |
Expand Down Expand Up @@ -149,7 +150,10 @@ Each product key in the `api:` block must have **exactly one** entry, with **exa
`spec:`. The build fails if a product sequence is empty or has more than one entry. Multiple
specs per product are not currently supported.

Product pages show an API product switcher in the left navigation. The list includes every declared API and a Back to hub option.
Product pages show an API product switcher on the far right of the grey secondary
top bar, immediately before the version picker. Isolated builds keep a product
`<select>` at the top of the left navigation. The list includes every declared API
and a Back to hub option.

Assembler API pages also show a Jump to API box at the top of that sidebar. The box searches API operations only. Isolated and air-gapped builds omit the box. Markdown docs pages do not get it back.

Expand Down Expand Up @@ -213,8 +217,9 @@ remotely through the index.

Versionless products (`versioning: serverless` and similar) render only the unversioned
`/api/doc/<key>/` path even when the index lists historical monikers. When more than one
version is rendered, API pages show a simple version dropdown at the top of the left navigation
rail. The dropdown links to each version's landing page.
version is rendered, assembler API pages show the same `version-dropdown` as Docs on the
far right of the grey secondary top bar. The current tree is labeled `latest`, and each
frozen major is `v9`, `v8`. Isolated builds keep a left-nav switcher with the same labels.

### Smoke-test every CloudFront spec locally

Expand Down Expand Up @@ -318,7 +323,7 @@ The `x-codeSamples` extension is a JSON array of objects, each with a `lang` and
]
```

Code samples appear in the right-hand **Examples** rail on every operation page that has the extension, regardless of HTTP method. When an operation also declares multiple named request/response `examples`, the rail builds **scenarios from request examples** (matched to response examples by title/summary) and exposes a `<select>` to switch between those request variants. Response examples whose titles do not match any request (typical error payloads) are shared across those scenarios as extra **status-code tabs** (for example `200`, `400`) on the light response card, without replacing a scenario-specific body for the same status. When there are no request examples, named response-only examples collapse into a single scenario so status tabs stay primary. Multi-language `x-codeSamples` render inside a code box with a language label and `<select>` in the header, attached to the scenario whose request body matches the Console sample. When a scenario has request JSON but no `x-codeSamples`, that JSON uses the same request code card (label `JSON`). There is no separate "Request" heading in the rail — only the **Examples** heading when multiple scenarios exist. Request and response code boxes show a non-selectable line-number gutter (selection and copy omit the numbers). Response bodies that are JSON objects/arrays use the Figma Card/Code token colors (black structure, green strings, blue booleans, maroon numbers); other payloads such as SSE streams stay plaintext so highlighting does not invent misleading colors. Single-line `curl` samples are reformatted for display (method and URL on the first line, one flag per line, with `\` continuations). OpenAPI example `description` text is not shown in the rail (the code samples and response JSON carry the content).
Code samples appear in the right-hand **Examples** rail on every operation page that has the extension, regardless of HTTP method. Below 1024px the rail is not hidden: it stacks as a single column under the operation reference. Below 768px the API sidebar uses the same hamburger checkbox as docs pages (`#pages-nav-hamburger`). When an operation also declares multiple named request/response `examples`, the rail builds **scenarios from request examples** (matched to response examples by title/summary) and exposes a header-only **Examples** card with a chrome-less `<select>` to switch between those request variants. Response examples whose titles do not match any request (typical error payloads) are shared across those scenarios as extra **status-code tabs** (for example `200`, `400`) on the light response card, without replacing a scenario-specific body for the same status. When there are no request examples, named response-only examples collapse into a single scenario so status tabs stay primary. Multi-language `x-codeSamples` render inside a code box with a method chip, endpoint, and language `<select>` in the header, attached to the scenario whose request body matches the Console sample. When a scenario has request JSON but no `x-codeSamples`, that JSON uses the same request code card. The rail has no standalone **Examples** heading: the label lives in the header-only card when there are multiple scenarios. Request and response code boxes show a non-selectable line-number gutter (selection and copy omit the numbers). Response bodies that are JSON objects/arrays use the Figma Card/Code token colors (black structure, green strings, blue booleans, maroon numbers); other payloads such as SSE streams stay plaintext so highlighting does not invent misleading colors. Single-line `curl` samples are reformatted for display (method and URL on the first line, one flag per line, with `\` continuations). OpenAPI example `description` text is not shown in the rail (the code samples and response JSON carry the content).

When an operation has **no** `x-codeSamples`, the API Explorer synthesizes a minimal **Console** and **curl** sample from the HTTP method, path, required query parameters, required headers (for example `kbn-xsrf`), and the document `servers` URL so the examples rail is never empty. Author-provided `x-codeSamples` always win over these synthetic samples. When the rail has samples (or request examples) but the operation declares response status codes without example bodies, the rail still shows status-code tabs: responses with no content render **No body**, and responses that declare a content type/schema but no example render **No example**.

Expand Down Expand Up @@ -427,7 +432,7 @@ The document-level `x-tagGroups` extension (from [Redocly](https://redocly.com/d
}
```

The default sidebar matches bump.sh. Tags are top-level folders. Each OpenAPI operation is a visible child of its tag.
The default sidebar matches bump.sh. The product overview, Authentication, Servers, and any `children:` markdown pages sit in one group. A divider separates that group from tag folders. Each OpenAPI operation is a visible child of its tag.

Classification folders, collapsing operations that share a grouping key into one endpoint, and Types pages require `FEATURE_API_NAV_GROUPING` (the `api-nav-grouping` feature flag). That flag is off by default.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,9 @@ private static TypeAnnotation WithTypeLink(TypeAnnotation type, TypePageLink? ty

if (sortedOptions.Length > 0 || expansion.HasUnionOptions)
{
var badgeOptions = expansion.HasUnionOptions ? [] : sortedOptions;
var badgeOptions = expansion.HasUnionOptions
? []
: sortedOptions.Where(static o => !SchemaHelpers.IsInternalSchemaName(o)).ToArray();
return new UnionDisplay
{
Kind = UnionDisplayKind.Badges,
Expand Down Expand Up @@ -629,7 +631,9 @@ private static bool IsAncestorType(string? typeName, IReadOnlySet<string> ancest

variants.Add(new ApiUnionVariant
{
DisplayName = variant.IsArray && variant.Name.EndsWith("[]") ? variant.Name[..^2] : variant.Name,
DisplayName = SchemaHelpers.ReadableSchemaName(
variant.IsArray && variant.Name.EndsWith("[]") ? variant.Name[..^2] : variant.Name
),
IsArrayVariant = variant.IsArray,
IsObjectType = variant.IsObject,
AnchorId = optionId,
Expand Down Expand Up @@ -723,7 +727,7 @@ private static TypeAnnotation BuildAnnotation(TypeInfo typeInfo, bool hasActualP
{
AppendArrayPrefix(spans);
AppendArrayKeywordSpans(spans, typeInfo, hasActualProperties);
spans.Add(NamedTypeSpan(typeName, typeInfo.SchemaRef, typeInfo.IsValueType));
AppendDisplayedTypeName(spans, typeInfo, hasActualProperties);
return new TypeAnnotation(spans);
}

Expand All @@ -737,7 +741,7 @@ private static TypeAnnotation BuildAnnotation(TypeInfo typeInfo, bool hasActualP

if (typeInfo.HasLink)
AppendObjectIcon(spans);
spans.Add(NamedTypeSpan(typeName, typeInfo.SchemaRef, typeInfo.IsValueType));
AppendDisplayedTypeName(spans, typeInfo, hasActualProperties);
return new TypeAnnotation(spans);
}

Expand Down Expand Up @@ -795,7 +799,36 @@ private static void AppendDictionarySpans(List<TypeSpan> spans, TypeInfo typeInf
spans.Add(new TypeSpan(" to ", Bare: true));
if (typeInfo.HasLink || hasActualProperties)
AppendObjectIcon(spans);
spans.Add(NamedTypeSpan(valueTypeName, null));
AppendInternalOrNamed(spans, valueTypeName, typeInfo.HasLink || hasActualProperties);
}

private static void AppendDisplayedTypeName(List<TypeSpan> spans, TypeInfo typeInfo, bool hasActualProperties)
{
var typeName = typeInfo.TypeName ?? "unknown";
if (!SchemaHelpers.IsInternalSchemaName(typeName))
{
spans.Add(NamedTypeSpan(typeName, typeInfo.SchemaRef, typeInfo.IsValueType));
return;
}

if (typeInfo.IsEnum || typeInfo.IsUnion || typeInfo.IsValueType || typeInfo.HasLink)
return;
if (typeInfo.IsObject && hasActualProperties)
return;

spans.Add(new TypeSpan("object", SchemaHelpers.PrimitiveCssClass));
}

private static void AppendInternalOrNamed(List<TypeSpan> spans, string typeName, bool labeledAlready)
{
if (!SchemaHelpers.IsInternalSchemaName(typeName))
{
spans.Add(NamedTypeSpan(typeName, null));
return;
}

if (!labeledAlready)
spans.Add(new TypeSpan("object", SchemaHelpers.PrimitiveCssClass));
}

private static void AppendWrapperKeyword(List<TypeSpan> spans, string keyword, string cssClass)
Expand All @@ -819,12 +852,12 @@ private static void AppendUnionPartSpans(List<TypeSpan> spans, string part)
{
if (!part.EndsWith("[]", StringComparison.Ordinal))
{
spans.Add(NamedTypeSpan(part, null));
AppendInternalOrNamed(spans, part, labeledAlready: false);
return;
}

AppendArrayPrefix(spans);
spans.Add(NamedTypeSpan(part[..^2], null));
AppendInternalOrNamed(spans, part[..^2], labeledAlready: false);
}

private static TypeSpan NamedTypeSpan(string typeName, string? schemaRef, bool isValueType = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@if (Model.ExternalDocs is not null)
{
<dd class="external-docs-row">
<a href="@Model.ExternalDocs.Url" class="docs-reference-btn docs-reference-btn-sm" @(Model.ExternalDocs.IsElasticDocs ? "" : "target=\"_blank\" rel=\"noopener\"")>
<a href="@Model.ExternalDocs.Url" class="docs-reference-btn" @(Model.ExternalDocs.IsElasticDocs ? "" : "target=\"_blank\" rel=\"noopener\"")>
@Model.ExternalDocs.LinkText
</a>
</dd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
{
<span class="@SchemaHelpers.WrapperObjectIconCssClass">{}</span>
}
<code class="schema-type"><span class="@SchemaHelpers.TypeAtomCssClassOrNull(variant.DisplayName)">@variant.DisplayName</span></code>
@if (!SchemaHelpers.IsInternalSchemaName(variant.DisplayName))
{
<code class="schema-type"><span class="@SchemaHelpers.TypeAtomCssClassOrNull(variant.DisplayName)">@variant.DisplayName</span></code>
}
</div>
@if (variant.ShowProperties && variant.Properties is not null)
{
Expand Down
56 changes: 37 additions & 19 deletions src/Elastic.ApiExplorer/Infrastructure/ApiBreadcrumb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,38 @@ public sealed record ApiBreadcrumb(string Title, string? Url)
}

/// <summary>
/// Visible crumbs plus optional overflow (EUI Page breadcrumbs, max 4).
/// When overflowing: first two, ellipsis, last two.
/// Full crumb list. The first crumb and the current page stay visible; the
/// client collapses middle crumbs into an ellipsis dropdown when the row is tight.
/// </summary>
public sealed record ApiBreadcrumbTrail(
IReadOnlyList<ApiBreadcrumb> Head,
IReadOnlyList<ApiBreadcrumb> Overflow,
IReadOnlyList<ApiBreadcrumb> Tail
)
public sealed record ApiBreadcrumbTrail(IReadOnlyList<ApiBreadcrumb> Items)
{
public static readonly ApiBreadcrumbTrail Empty = new([], [], []);
public static readonly ApiBreadcrumbTrail Empty = new([]);

public bool HasOverflow => Overflow.Count > 0;

public bool IsEmpty => Head.Count == 0 && Tail.Count == 0;
public bool IsEmpty => Items.Count == 0;
}

public sealed record ApiBreadcrumbsView(ApiBreadcrumbTrail Trail, string HxAttributes);

public static class ApiBreadcrumbBuilder
{
public const int MaxVisible = 4;
public const string CatalogCrumbTitle = "APIs";

public static ApiBreadcrumbTrail Build(INavigationItem current, string currentTitle, string? rootTitle, string? catalogUrl = null) =>
TrailFrom(Collect(current, currentTitle, rootTitle, catalogUrl));

public static ApiBreadcrumbTrail Build(INavigationItem current, string currentTitle, string? rootTitle) =>
Split(Collect(current, currentTitle, rootTitle));
internal static ApiBreadcrumbTrail TrailFrom(IReadOnlyList<ApiBreadcrumb> items)
{
if (items.Count == 0 || items.All(static crumb => crumb.IsCurrent))
return ApiBreadcrumbTrail.Empty;
return new ApiBreadcrumbTrail(items);
}

internal static IReadOnlyList<ApiBreadcrumb> Collect(INavigationItem current, string currentTitle, string? rootTitle)
internal static IReadOnlyList<ApiBreadcrumb> Collect(
INavigationItem current,
string currentTitle,
string? rootTitle,
string? catalogUrl = null
)
{
var items = new List<ApiBreadcrumb>();
foreach (var parent in current.GetParents().Reverse())
Expand All @@ -60,6 +66,10 @@ internal static IReadOnlyList<ApiBreadcrumb> Collect(INavigationItem current, st

var currentLabel = string.IsNullOrWhiteSpace(currentTitle) ? current.NavigationTitle : currentTitle;
items.Add(new ApiBreadcrumb(currentLabel, null));

if (ShouldPrependCatalog(catalogUrl, current.Url, items))
items.Insert(0, new ApiBreadcrumb(CatalogCrumbTitle, catalogUrl));

return items;
}

Expand All @@ -78,11 +88,19 @@ internal static string ToJsonLd(IReadOnlyList<ApiBreadcrumb> crumbs, Uri? canoni
return JsonSerializer.Serialize(new BreadcrumbsList { ItemListElement = items }, BreadcrumbsContext.Default.BreadcrumbsList);
}

internal static ApiBreadcrumbTrail Split(IReadOnlyList<ApiBreadcrumb> items)
private static bool ShouldPrependCatalog(string? catalogUrl, string currentUrl, IReadOnlyList<ApiBreadcrumb> items)
{
if (items.Count <= MaxVisible)
return new ApiBreadcrumbTrail(items, [], []);
if (string.IsNullOrWhiteSpace(catalogUrl))
return false;
if (SameUrl(currentUrl, catalogUrl))
return false;
return items.Count == 0 || !SameUrl(items[0].Url, catalogUrl);
}

return new ApiBreadcrumbTrail(items.Take(2).ToArray(), items.Skip(2).Take(items.Count - 4).ToArray(), items.TakeLast(2).ToArray());
private static bool SameUrl(string? left, string? right)
{
if (left is null || right is null)
return false;
return string.Equals(left.TrimEnd('/'), right.TrimEnd('/'), StringComparison.Ordinal);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@
namespace Elastic.ApiExplorer.Infrastructure;

/// <summary>Multi-language code sample widget with a header language selector.</summary>
public record ApiCodeSampleModel(string IdPrefix, IReadOnlyList<CodeSample> Samples);
public record ApiCodeSampleModel(
string IdPrefix,
IReadOnlyList<CodeSample> Samples,
string? HttpMethod = null,
string? Route = null,
IReadOnlyList<ApiSelectOption>? Examples = null
);
19 changes: 19 additions & 0 deletions src/Elastic.ApiExplorer/Infrastructure/ApiSelectModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

namespace Elastic.ApiExplorer.Infrastructure;

public sealed record ApiSelectOption(string Label, string Value, bool Selected);

/// <summary>Custom details dropdown used for language and example pickers.</summary>
public sealed record ApiSelectModel
{
public required string AriaLabel { get; init; }
public required IReadOnlyList<ApiSelectOption> Options { get; init; }
public string ExtraClass { get; init; } = "";
public string? Id { get; init; }
public string? SyncGroup { get; init; }

public ApiSelectOption Current => Options.FirstOrDefault(static o => o.Selected) ?? Options[0];
}
35 changes: 34 additions & 1 deletion src/Elastic.ApiExplorer/Infrastructure/ApiVersionSwitcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System.Text.Json;
using System.Text.Json.Serialization;
using Elastic.Documentation.Configuration.Versions;

namespace Elastic.ApiExplorer.Infrastructure;

public static class ApiVersionSwitcher
Expand All @@ -20,13 +24,42 @@ string currentMoniker
.OrderByDescending(m => m == "main" ? int.MaxValue : ParseMajor(m))
.Select(
m => new ApiVersionSwitcherItem(
Label: m == "main" ? "Latest" : $"{m}.x",
Label: m == "main" ? "latest" : $"v{m}",
Url: $"{ApiUrlBuilder.ProductRoot(urlPathPrefix, ApiUrlBuilder.ProductSuffix(apiKey, m))}/",
Selected: m == currentMoniker
)
)
.ToArray();
}

public static string? CurrentVersionLabel(VersioningSystem? versioning, IReadOnlyList<ApiVersionSwitcherItem> items)
{
if (versioning is { IsVersionless: false })
return $"{versioning.Base.Major}.{versioning.Base.Minor}+";

foreach (var item in items)
{
if (item.Label.EndsWith('+'))
return item.Label;
}

return null;
}

public static string SerializeDropdownItems(IReadOnlyList<ApiVersionSwitcherItem> items)
{
if (items.Count == 0)
return "[]";

var payload = items.Select(static i => new ApiVersionDropdownJsonItem(i.Label, i.Url, false, null)).ToArray();
return JsonSerializer.Serialize(payload, ApiVersionDropdownJsonContext.Default.ApiVersionDropdownJsonItemArray);
}

private static int ParseMajor(string moniker) => int.TryParse(moniker, out var major) ? major : 0;
}

internal sealed record ApiVersionDropdownJsonItem(string Name, string? Href, bool Disabled, ApiVersionDropdownJsonItem[]? Children);

[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
[JsonSerializable(typeof(ApiVersionDropdownJsonItem[]))]
internal sealed partial class ApiVersionDropdownJsonContext : JsonSerializerContext;
Loading
Loading