[Markdowns API] Polish OAS docs and co-locate examples with route code#1
Closed
florent-leborgne wants to merge 6 commits into
Closed
[Markdowns API] Polish OAS docs and co-locate examples with route code#1florent-leborgne wants to merge 6 commits into
florent-leborgne wants to merge 6 commits into
Conversation
Aligns the markdown library item API with the conventions used by the dashboards and visualizations APIs: - Override the technical-preview boilerplate description on POST, GET by ID, PUT, and DELETE with concrete per-operation descriptions (the shared description in commonRouteConfig was used as-is on every non-search route, so the rendered docs showed the preview disclaimer in place of the operation description). - Rename the OAS tag from `markdown` (lowercase, singular) to `Markdowns` (PascalCase, plural) to match `Dashboards` and `Visualizations`. - Add descriptions to `content`, `settings`, and `settings.open_links_in_new_tab` in the markdown embeddable state schema. These fields are spread into the API's request and response bodies and were previously undocumented. - Use the same phrasing as the dashboards API for the `id` path parameter on GET by ID and DELETE. Co-authored-by: Cursor <cursoragent@cursor.com>
…les) Mirrors what dashboards.overlays.yaml and visualizations.overlays.yaml do for their respective tags: - A tag-level description for `Markdowns` with intro, when-to-use guidance, get-started block, and a brief reference to the dashboards panel `ref_id` pattern for cross-discoverability. - Minimal request body and response examples on POST, GET list, GET by ID, and PUT operations. This also clears the `kbn-validate-oas` errors that complained about missing `examples` on every markdowns content body. - cURL and Console code samples on every operation, so the rendered docs have a runnable snippet in the right-hand column. Wires the new overlay into the standard pipeline (between visualizations and bump-slim) and into the external pipeline (between visualizations and strip_request_examples). The strip overlay is extended to also drop the markdowns POST and PUT request examples in the external render, to match the existing dashboards/visualizations handling. Co-authored-by: Cursor <cursoragent@cursor.com>
Mirrors the pattern introduced for the Dashboards and Visualizations APIs in elastic#270181: typed example bodies, code samples, descriptions, and the assembled OAS operation objects now live in `server/api/oas_examples.ts`, alongside the route definitions that consume them via `addVersion({ options: { oasOperationObject } })`. The post-processing overlay (`oas_docs/overlays/markdowns.overlays.yaml`) is trimmed to tag-level narrative (getting-started content, externalDocs, display name). Operation-level examples and code samples no longer have to be maintained in a separate YAML layer. Also fixes a path typo in the search route description (`/api/markdown/{id}` -> `/api/markdowns/{id}`). Note: depends on elastic#270181 for the `options.oasOperationObject` type broadening (async return + `description` + `x-codeSamples`). Typecheck fails on this branch until that PR lands and our base branch absorbs it; the runtime behavior already works because the OAS generator deep-merges whatever the thunk returns. Co-authored-by: Cursor <cursoragent@cursor.com>
The tag-level externalDocs block and the in-prose "markdown panel" link both pointed at the generic Dashboards page. The canonical reference for markdown content is `explore-analyze/visualize/text-panels`, which also has a "Save and reuse Markdown panels across dashboards" section that matches exactly what this API enables. Co-authored-by: Cursor <cursoragent@cursor.com>
…slim
Three small follow-ups to round out the Markdowns API docs polish.
1. content field — clarify that the value is GitHub-flavored Markdown and
list the supported elements. The previous description ("The markdown
text content rendered by the panel.") didn't tell API users what they
could actually put in there.
2. Example payloads — replace the placeholder one-sentence body with a
realistic Markdown document that exercises headings, paragraphs, bold,
inline code, bullet lists, blockquotes, and links. Refactor the
response examples to reuse markdownCreateBody / markdownUpdateBody so
request and response examples can't drift.
3. kibana.overlays.bump_slim.yaml — add the Markdowns API to the
tech-preview redirect treatment used for Dashboards and
Visualizations. The slim pipeline now strips each Markdowns operation
down to a redirect notice pointing at the external full-spec host;
the full reference still ships through kibana.external.yaml.
Co-authored-by: Cursor <cursoragent@cursor.com>
House style avoids em dashes. Replaces the em dashes I introduced in the last few commits with commas, colons, or rewrites, in oas_examples.ts, embeddable/schemas.ts, and the Markdowns blocks added to kibana.overlays.bump_slim.yaml. Leaves the pre-existing Dashboards and Visualizations blocks alone (out of scope for this PR). Co-authored-by: Cursor <cursoragent@cursor.com>
Owner
Author
|
was made for the example and to use as ref for the dev team, closing |
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.
Summary
Polishes the public Markdowns API OpenAPI documentation and brings it in line with the conventions used by the dashboards and visualizations APIs.
What the PR does
Markdowns API source code
commonRouteConfig.content,settings, andsettings.open_links_in_new_tabschema fields all havemeta.description. Thecontentdescription spells out that it's GitHub-flavored Markdown and lists the supported elements.idpath parameter on GET by ID, DELETE, and PUT uses the same phrasing as the dashboards API:The markdown library item ID, as returned by the create or search endpoints.Markdowns(PascalCase, plural), matchingDashboardsandVisualizations.Examples and code samples co-located with the routes
src/platform/plugins/shared/dashboard_markdown/server/api/oas_examples.tsdefines the typed example payloads, cURL and Console code samples, and operation-level descriptions for all five endpoints. The five exported operation objects are lazy-imported by eachregister_*_route.tsviaaddVersion({ options: { oasOperationObject } }), following the pattern introduced for the dashboards and visualizations APIs in elastic#270181.Example payloads are typed with
satisfiesagainst the schema-derived response types, so a schema change that breaks an example fails the build. Request bodies are defined once and reused asdatain the response examples, so they can't drift.OAS overlays
oas_docs/overlays/markdowns.overlays.yamlprovides the tag-level narrative: when to use the API, how to authenticate, how to reference a library item from a dashboard, plusexternalDocspointing at the Text panels page and theMarkdownsdisplay name. Operation-level examples and code samples are not here, they come from TypeScript.oas_docs/overlays/kibana.overlays.bump_slim.yamlgives the Markdowns API the same technical-preview redirect treatment as the dashboards and visualizations APIs: in the public Bump bundle (kibana.yaml), each operation collapses to a notice linking to the external full reference atelastic.github.io/dashboards-api-spec. The full spec still ships throughkibana.external.yaml.oas_docs/overlays/kibana.overlays.strip_request_examples.yamlstrips MarkdownsrequestBody.examplesfrom the external bundle alongside the dashboards and visualizations entries (same temporary workaround until the external renderer handlesrequestBody.examplesnatively).oas_docs/makefilewires the new overlay into both the standard and external pipelines.Dependencies and limitations
options.oasOperationObjecttype broadening (async return, plusdescriptionandx-codeSampleson the operation object). Typecheck fails on this branch until that PR lands and the base branch absorbs it. Runtime behavior is already correct because the OAS generator deep-merges whatever the thunk returns.