[Console] Add Kibana API route autocomplete in Dev Tools Console#272048
Draft
shahzad31 wants to merge 1 commit into
Draft
[Console] Add Kibana API route autocomplete in Dev Tools Console#272048shahzad31 wants to merge 1 commit into
shahzad31 wants to merge 1 commit into
Conversation
Dev Tools Console can call Kibana APIs via the `kbn:` URL prefix
(e.g. `GET kbn:/api/data_views`) but offered no autocompletion for those
routes. This adds route-name and query-parameter autocomplete for `kbn:`
URLs, reusing Console's existing Elasticsearch matcher engine.
- core http: add a lightweight, public `http.getRegisteredRoutes()` that
enumerates every registered route (path, method, access, description,
versioned) without handlers or schemas. An opt-in
`includeQueryParameters` also extracts each route's query parameters
from its validation schema.
- @kbn/router-to-openapispec: add `extractRouteQueryParameters`
(query-only) that reuses the OpenAPI converter so config-schema and Zod
schemas, versioned or not, are handled. io-ts / server-route-repository
routes (e.g. SLO, APM) are not yet covered.
- Console server: build Kibana autocomplete definitions from the registry
(public by default, internal in dev mode), surface query parameters as
`url_params`, and extend `/api/console/api_server` to return
`{ es, kibana }`.
- Console client: load a second `kbn:` matcher and route `kbn:`-prefixed
URLs to it, showing supported methods and re-triggering suggestions
while the URL is edited.
Part of elastic#130661
Co-authored-by: Cursor <cursoragent@cursor.com>
|
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
|
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
Dev Tools Console can call Kibana APIs via the
kbn:URL prefix (e.g.GET kbn:/api/data_views), but there was no autocompletion for those routes (open gap: #130661). This PR adds route-name and query-parameter autocomplete forkbn:URLs, reusing Console's existing Elasticsearch matcher engine so everything downstream (tree walking, range math, prefix filtering) is shared.Type
kbn:after a method and Console now suggests Kibana routes, the HTTP methods each supports, and — after?— the route's query parameters.What's included
http.getRegisteredRoutes()that enumerates every registered route (path, method, access, description, versioned) without handlers or schemas. An opt-in{ includeQueryParameters: true }also extracts each route's query parameters from its validation schema.@kbn/router-to-openapispec: newextractRouteQueryParametershelper (query-only) that reuses the OpenAPI converter, so@kbn/config-schemaand Zod schemas — versioned or not — are handled consistently. Returns a lightweight, serializable shape (noopenapi-typesleak into core's public contract).url_params, and extends/api/console/api_serverto return{ es, kibana }.kbn:matcher, routeskbn:-prefixed URLs to it, advertises thekbn:entry point at the start of a URL, shows supported methods, and re-triggers suggestions while the URL is being edited.Known limitation / follow-up
Routes built on
@kbn/server-route-repositorywith io-ts schemas (e.g. SLO, much of APM, infra, dataset-quality) register aPassThroughAnyplaceholder onvalidate.queryand decode io-ts inside the handler, so their query schema never reaches the registered route. As a result these routes get route-name autocomplete but no query-parameter suggestions yet. Closing this would require surfacing the io-ts query schema at the repository layer (a shared platform package), tracked as a follow-up. Routes on that repository that use Zod already work.How to test
GET kbn:— Kibana routes should autocomplete (with method hints).GET kbn:/api/synthetics/monitors?— query params should suggest (page,perPage,sortOrder, …).kbn:entry point appears at the start of a URL.Checklist
@kbn/server-route-repository) routes — follow-upPart of #130661
Made with Cursor