[Lens] Improve Visualizations API documentation#259842
Closed
florent-leborgne wants to merge 37 commits into
Closed
[Lens] Improve Visualizations API documentation#259842florent-leborgne wants to merge 37 commits into
florent-leborgne wants to merge 37 commits into
Conversation
Contributor
|
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
fe81727 to
7b8c2e5
Compare
5 tasks
c000f99 to
c93d2bf
Compare
This was referenced Apr 2, 2026
369a6bb to
d2f9c2b
Compare
df3a6de to
0175dc1
Compare
Comment on lines
+25
to
+28
| @node scripts/strip_additional_properties.js oas_docs/output/kibana.yaml | ||
| @node scripts/strip_discriminators.js oas_docs/output/kibana.yaml | ||
| @node scripts/strip_additional_properties.js oas_docs/output/kibana.serverless.yaml | ||
| @node scripts/strip_discriminators.js oas_docs/output/kibana.serverless.yaml |
Contributor
There was a problem hiding this comment.
🔴 Critical oas_docs/makefile:25
Running make api-docs fails with ENOENT when the api-docs-postprocess target executes. The Makefile paths oas_docs/output/kibana.yaml resolve to oas_docs/oas_docs/output/kibana.yaml relative to the working directory, but the scripts read files without resolving against REPO_ROOT. This matches the pattern used by api-docs-overlay and api-docs-lint, which expect to run from the oas_docs/ directory. Consider changing paths to output/kibana.yaml to match the convention used in sibling targets, or modify the scripts to resolve paths using REPO_ROOT.
- @node scripts/strip_additional_properties.js oas_docs/output/kibana.yaml
- @node scripts/strip_discriminators.js oas_docs/output/kibana.yaml
- @node scripts/strip_additional_properties.js oas_docs/output/kibana.serverless.yaml
- @node scripts/strip_discriminators.js oas_docs/output/kibana.serverless.yaml🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file oas_docs/makefile around lines 25-28:
Running `make api-docs` fails with `ENOENT` when the `api-docs-postprocess` target executes. The Makefile paths `oas_docs/output/kibana.yaml` resolve to `oas_docs/oas_docs/output/kibana.yaml` relative to the working directory, but the scripts read files without resolving against `REPO_ROOT`. This matches the pattern used by `api-docs-overlay` and `api-docs-lint`, which expect to run from the `oas_docs/` directory. Consider changing paths to `output/kibana.yaml` to match the convention used in sibling targets, or modify the scripts to resolve paths using `REPO_ROOT`.
Enrich the Visualizations API with overlay content, examples, and improved descriptions for the upcoming public release in 9.4. Route and schema improvements: - Tighter operation descriptions with consistent third-person voice - Parameter descriptions with valid values, defaults, and field relationships - Improved error response descriptions - Fix ignore_global_filters description to explain dashboard filter bar behavior Overlay (oas_docs/overlays/visualizations.overlays.yaml): - Tag intro with getting started guide, chart types table with links to docs and API payload examples, DSL vs ES|QL mode explanation - Request/response examples for 4 chart types (metric, XY, pie, data table) - cURL and Console code samples for all 5 endpoints - Sample dataset note with link Example files (oas_docs/examples/): - 10 new YAML files: 4 request + 4 response examples, plus get and search responses - All validated against a live 9.4 instance (4/4 DSL examples pass) Makefile: - Wired visualizations overlay into the ESS and serverless overlay chains Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add bold anchors to auth blockquote for scannability - Add common fields sentence after chart types table - Rename "DSL mode" to "index/data view mode" (overlay + route files) - Remove stray `time_scale: null` line (invalid JSON) from PUT Console sample Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace ~60 tautological schema descriptions with meaningful, actionable text across shared and chart-specific schema files. These descriptions flow into the generated OpenAPI spec, so improving them here permanently improves the published API reference. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add descriptions to all response meta fields (created_at, updated_at, managed, origin_id, etc.), search response pagination fields, and the create endpoint optional id parameter. Also add "adapting examples" and error handling guidance to the overlay tag description. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Both schemas spread ...labelSharedProp which already defines `label`, then immediately override it with an identical local definition. Remove the dead overrides so the shared definition is the single source of truth. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…e schemas" This reverts commit 2d9a03d.
Restore searchOptionsSchemas.page and .perPage references with .extendsDeep() to add descriptions without changing schema types. The previous change inadvertently switched these from optional to required. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace .extendsDeep() calls on shared schema refs with inline schema definitions that include meta.description directly. This is needed because .extendsDeep() on maybe()-wrapped schemas does not propagate descriptions into the generated OpenAPI spec. Trade-off: these definitions are decoupled from the shared schemas in kbn-content-management-utils. If the shared schemas add descriptions in the future, these can be switched back to shared refs. Types must stay in sync manually until then. Affected fields: - common.ts: response meta (type, created_at, updated_at, created_by, updated_by, origin_id, managed) and response id - create.ts: overwrite query param - search.ts: request query (fields, search_fields) and response meta (page, per_page) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract the core description paragraph above the "Get started" heading so it renders as the tag summary in the API reference. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ls renames - terms size → limit in 6 request/response YAML examples - alignments → labels (with correct alignment: sub-field) in 4 metric examples - overlay: same fixes in 4 code samples and error guidance text Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Update ES|QL warning to mention Dashboards API as a workaround for creating ES|QL visualizations (currently blocked on this API) - Add "Next steps" section pointing to the Dashboards API for embedding visualizations as panels (by reference or inline by value) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…raph - Add 'When to use Visualizations API vs Dashboards API' section - Fix auth callout link to include '> Authentication' - Simplify bridge paragraph: short intro + transition to subsections Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Split into #### Index/data view mode and #### ES|QL mode sub-headings - Use bullet points for index vs dataView options within Index mode Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add meta.title to schema variants so the generated OpenAPI spec shows human-readable labels instead of generic 'object' in oneOf/anyOf tabs: - metric.ts: description on primary/secondary metric oneOf - bucket_ops.ts: titles on rank_by variants (Alphabetical, Rare terms, Significant terms, Column, Custom) - xy.ts: titles on Y-axis and X-axis extent variants (Full, Focus, Custom) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Label each code sample as 'Action - cURL' and 'Action - Console' so the dropdown clearly shows which format each sample uses. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Human-readable titles for collapseBy, datatableDensity, lensPanelFilters, direction/orientation enums, xy annotations, decorations, and fitting schemas. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
These files are regenerated by `make api-docs` and should not be committed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…verlay Follows the rename in filter.ts from the main merge. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ficant option - create_pie_visualization_request.yaml: donut_hole medium→m, visible→visibility, value_display→values - bucket_ops.ts: restore missing significant option in rank_by oneOf; remove redundant label definition in bucketHistogramOperationSchema Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ngSchema Remove alignments, fit, icon (primary) and prefix, label_position (secondary) from metricStatePrimaryMetricOptionsSchema and metricStateSecondaryMetricOptionsSchema. These fields don't exist in main — the equivalent capabilities live in the metricStylingSchema under the `styling` property. Adding them would change the API surface. Keep the description improvements on subtitle and compareToSchemaShared. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Align all YAML examples and overlay inline code with the schema rename from `dataset` to `data_source` (index→data_view_spec, dataView→data_view_reference, index→index_pattern, id→ref_id) that landed in main via #260914. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replace "Lens documentation" with "visualizations documentation" in the overlay narrative text. Update code comment in common.ts. The saved object type value remains `lens` — only user-facing prose changes. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Add trailing periods to rank_by direction descriptions. Improve axis title, legend truncation, and panel filters descriptions with defaults, valid values, and actionable context. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…rity Add trailing periods and improve terse descriptions across all 15 chart schema files (xy, datatable, metric, pie, gauge, treemap, tagcloud, heatmap, waffle, mosaic, legacy_metric, region_map, partition_shared, shared, color). ~228 description edits total. Only meta.description strings changed — no field names, types, imports, or code logic altered. Improvements sourced strictly from visible code context (defaultValue, schema.literal, min/max, JSDoc). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Rewrite opening: direct CRUD + library context, remove marketing - Move 'Get started' first, comparison section last - Add required fields note before chart types table - Rewrite data source modes intro with when-to-use criterion - Define 'Kibana aggregations' inline - Fix ES|QL section: remove passive/vague 'best for' phrasing - Change ES|QL limitation from info to warn callout - Tighten sample data note - Expand error handling: add 401/404, fix oneOf jargon - Replace em dashes with colons throughout Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…schemas - Add 403 Forbidden to error handling - Verify chart type docs link is correct - Strip additionalProperties:false from all schemas in overlay Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Replace vis_api_ meta.id values with readable kebab-case IDs (enums: orientation, simple-orientation, direction; xy.ts: xy-domain-*, xy-axis-config; shared/filter: panel-filters, filter-simple, filter-with-label) - Add strip_additional_properties.js, strip_discriminators.js to oas_docs/scripts/ - Wire api-docs-postprocess target into makefile after api-docs-overlay Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Reapply content improvements (descriptions, punctuation, wording) without changing meta.id values. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
5ceb084 to
0e18c5a
Compare
Member
Author
|
Superseded by a series of smaller PRs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #236265
Summary
Improve the Visualizations API documentation ahead of its public release in 9.4. This PR (Kibana) and a companion docs-content PR work together to create a cohesive documentation experience across the API reference and the narrative chart documentation.
Related: #260969 (Dashboards API docs, same pattern)
Documentation strategy
Users discovering the Visualizations API will follow one of three paths. Our changes ensure each path leads to success:
Path 1: Start from the API reference
A user lands on the API docs and wants to create a visualization. The tag intro orients them: what chart types exist, how data sources work (DSL vs ES|QL), and what the current limitations are. They pick an endpoint, see a concise description, copy a code sample, and it works out of the box with sample data. If they need a more complex example, the chart types table links directly to tested payload examples on each chart page.
Path 2: Start from the chart documentation
A user is reading about how to build a bar chart or a metric in the UI. At the bottom of each example and advanced scenario, a collapsible dropdown shows the equivalent API payload. They can copy it, modify it, and use it in their automation. The dropdown links back to the API reference for the full schema.
Path 3: Explore the schema
A user browses the request body schema to understand all available options. Every parameter they encounter has a clear, actionable description explaining what it does, its valid values, defaults, and relationships to other fields.
Changes in this PR (Kibana)
API reference intro (overlay)
oneOfvalidation errorsEndpoint descriptions (route files)
since: '9.4.0'on all availability configsSchema property descriptions (~320 fields across config_builder and route schemas)
Replaced tautological descriptions with actionable text across shared and chart-specific schema files. Every description now ends with a period, includes defaults and valid values where available, and provides context beyond restating the field name.
Files improved (config_builder):
shared.ts—label,title,description,collapseBy, axis title, legend truncation, panel filtersmetric_ops.ts—reduced_time_range,time_shift,time_scale,formula,field,empty_as_null,static value,column(ES|QL),time_field,percentile,windowbucket_ops.ts— date histogram, terms (fields,limit,increase_accuracy,includes/excludes,other_bucket,rank_bywith titles), histogram, rangeformat.ts—decimals,suffix,compact,from/to(duration),patternfilter.ts—expression, filterlabelcolor.ts— color by value, static color, apply color tocharts/xy.ts— ~90 descriptions: layer types, legend, axis config, domain, scale, fitting, curve, overlays, decorations, annotations, reference linescharts/datatable.ts— ~26 descriptions: density, pagination, sorting, alignment, summary rows, one-click filtercharts/metric.ts—subtitle, comparepalette/icon/value, styling (labels, values, icon, secondary)charts/pie.ts— legend, slice labels, donut hole, values displaycharts/gauge.ts— shapes (bullet/circular), title, subtitle, tickscharts/heatmap.ts— axes, cells, legend, labelscharts/tagcloud.ts— orientation, font sizes, captioncharts/treemap.ts— legend, labels, metrics, breakdownscharts/waffle.ts— legend, metrics, breakdownscharts/mosaic.ts— legend, breakdowns, group breakdownscharts/legacy_metric.ts— labels, values, font sizecharts/partition_shared.ts— value display, nested legendcharts/region_map.ts— EMS boundaries, join fieldcharts/shared.ts— legend visibilityFiles improved (route schemas):
common.ts— inlinelensItemMetaSchemawith 7 described meta fieldscreate.ts—idparam,overwritequery paramsearch.ts—fields,search_fields,query,page,per_page,totalLens term de-emphasis
lensleft as-is (it's the actual value)data_sourcerename alignmentdataset→data_source,type: index→type: data_view_spec,index→index_pattern,type: dataView→type: data_view_reference,id→ref_id(per [Lens as Code] Use as code dataView schema #260914)Response and request parameter descriptions (route schema files)
created_at,updated_at,created_by,updated_by,managed,origin_id,type,idfields,search_fields,query,page,per_pagepage,per_page,totalidpath param,overwritequery paramExamples and code samples (overlay + YAML files)
The route schema files (
common.ts,create.ts,search.ts) define response meta and request query fields inline rather than referencing shared schemas fromkbn-content-management-utils. This is intentional:Why:
ExtendsDeepOptionsinkbn-config-schemadoes not include ametafield — it only supportsunknowns. Calling.extendsDeep({ meta: { description: '...' } })compiles without error (TypeScript doesn't enforce excess property checking at these call sites), but themetavalue is silently ignored and never propagated. Descriptions added this way are absent from the generated OpenAPI spec, resulting in undocumented fields in the published API reference. See item 9 in the findings gist for details.Trade-off: These inline definitions are decoupled from the shared
savedObjectSchemaandsearchOptionsSchemas. If the shared schemas change their types, the Lens route schemas won't automatically follow. The types are identical today and are unlikely to change (stable saved object fields), but this is a conscious trade-off.Alternatives:
ExtendsDeepOptionsto supportmetainkbn-config-schema— this would let API teams add descriptions to shared schemas without forking them, and is the cleanest platform-level fix.meta: { description }to the shared schemas inkbn-content-management-utils/src/schema.ts— all content management APIs would inherit descriptions. Lens-specific descriptions (e.g., "Alwayslens" fortype) could then use inline overrides only where needed.If the team prefers either alternative, these inline definitions can be reverted. Each affected file has a code comment explaining the rationale and pointing to
common.tsfor the full context.Changes in companion PR (elastic/docs-content#5645)
50 inline API payload dropdowns across all 13 chart type pages, placed after each individual example and advanced scenario:
Lens overview page: new "Create visualizations with the API" section linking to both stateful and serverless API docs
Integration test findings
All examples validated against a live 9.4 instance. Findings and testing scripts:
https://gist.github.com/florent-leborgne/21996938a5583965e3f0de59da6dedd5
Key items for the team:
metricNoESQLschema missingtype: "primary",labels,icon(ES|QL variant is correct)other_bucketruntime expects object, not booleanidpath param missing from POST speclensPanelFiltersdescription duplicated at array and items level.extendsDeep()does not supportmeta— descriptions silently dropped (see item 9 in gist)Version badges
Added
since: '9.4.0'to theavailabilityconfig on all 5 route definitions so the API docs render "Technical Preview; added in 9.4.0" badges.Preview
Latest combined preview (Dashboards + Visualizations): https://bump.sh/preview/111e0488-c656-40cb-8379-4d50cf4b1554