From 2792c48b5de67b66c9cf9a598a764059d7b86ea5 Mon Sep 17 00:00:00 2001 From: Florent Le Borgne Date: Tue, 14 Apr 2026 18:56:03 +0200 Subject: [PATCH 1/5] [Docs][Visualizations API] Add endpoint descriptions and field descriptions - Add operation descriptions and since: '9.4.0' to all 5 route files (create, search, get, update, delete) - Add field descriptions to search query params (fields, search_fields, query, page, per_page) and response meta (page, per_page, total) - Add id description to lensResponseItemSchema - Add overwrite description to lensCreateRequestQuerySchema (inline) - Add id descriptions to delete/get/update params schemas - Add field descriptions to asCodeMetaSchema in @kbn/as-code-shared-schemas (created_at, created_by, managed, owner, updated_at, updated_by, version) so all API consumers benefit Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .../shared-schemas/src/schemas/meta/schema.ts | 45 +++++++++++++++--- .../api/routes/visualizations/create.ts | 7 ++- .../api/routes/visualizations/delete.ts | 4 +- .../server/api/routes/visualizations/get.ts | 3 +- .../routes/visualizations/schema/common.ts | 8 ++-- .../routes/visualizations/schema/create.ts | 13 ++++-- .../routes/visualizations/schema/delete.ts | 2 +- .../api/routes/visualizations/schema/get.ts | 2 +- .../routes/visualizations/schema/search.ts | 46 +++++++++++++++---- .../routes/visualizations/schema/update.ts | 2 +- .../api/routes/visualizations/search.ts | 3 +- .../api/routes/visualizations/update.ts | 13 ++++-- 12 files changed, 113 insertions(+), 35 deletions(-) diff --git a/src/platform/packages/shared/as-code/shared-schemas/src/schemas/meta/schema.ts b/src/platform/packages/shared/as-code/shared-schemas/src/schemas/meta/schema.ts index c0acc406497ba..2da08e30f8e39 100644 --- a/src/platform/packages/shared/as-code/shared-schemas/src/schemas/meta/schema.ts +++ b/src/platform/packages/shared/as-code/shared-schemas/src/schemas/meta/schema.ts @@ -12,13 +12,44 @@ import { schema } from '@kbn/config-schema'; export const asCodeMetaSchema = schema.object( { - created_at: schema.maybe(schema.string()), - created_by: schema.maybe(schema.string()), - managed: schema.maybe(schema.boolean()), - owner: schema.maybe(schema.string()), - updated_at: schema.maybe(schema.string()), - updated_by: schema.maybe(schema.string()), - version: schema.maybe(schema.string()), + created_at: schema.maybe( + schema.string({ + meta: { description: 'Timestamp when the object was created (ISO 8601).' }, + }) + ), + created_by: schema.maybe( + schema.string({ + meta: { description: 'User profile ID of the user who created the object.' }, + }) + ), + managed: schema.maybe( + schema.boolean({ + meta: { + description: + 'When `true`, the object is managed by Kibana and cannot be edited by users.', + }, + }) + ), + owner: schema.maybe( + schema.string({ + meta: { description: 'Identifier of the plugin or team that owns this object.' }, + }) + ), + updated_at: schema.maybe( + schema.string({ + meta: { description: 'Timestamp when the object was last updated (ISO 8601).' }, + }) + ), + updated_by: schema.maybe( + schema.string({ + meta: { description: 'User profile ID of the user who last updated the object.' }, + }) + ), + version: schema.maybe( + schema.string({ + meta: { description: 'Internal version identifier for optimistic concurrency control.' }, + }) + ), }, { meta: { diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/create.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/create.ts index a804c436ae05f..85c4d3bf77d58 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/create.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/create.ts @@ -34,11 +34,16 @@ export const registerLensVisualizationsCreateAPIRoute: RegisterAPIRouteFn = ( path: LENS_VIS_API_PATH, access: LENS_API_ACCESS, summary: 'Create visualization', - description: 'Create a new visualization.', + description: [ + 'Creates a Lens visualization and saves it to the library.', + '', + 'ES|QL visualizations cannot be created through this endpoint.', + ].join('\n'), options: { tags: [LENS_API_TAG], availability: { stability: 'experimental', + since: '9.4.0', }, }, security: { diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/delete.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/delete.ts index 0d726ef424576..fe993f30b5962 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/delete.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/delete.ts @@ -25,11 +25,13 @@ export const registerLensVisualizationsDeleteAPIRoute: RegisterAPIRouteFn = ( path: `${LENS_VIS_API_PATH}/{id}`, access: LENS_API_ACCESS, summary: 'Delete visualization', - description: 'Delete a visualization by id.', + description: + 'Permanently deletes a Lens visualization. If the visualization is referenced by a dashboard panel, the panel shows an error after deletion.', options: { tags: [LENS_API_TAG], availability: { stability: 'experimental', + since: '9.4.0', }, }, security: { diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/get.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/get.ts index af419606aef4c..4f8dec2beab1f 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/get.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/get.ts @@ -29,11 +29,12 @@ export const registerLensVisualizationsGetAPIRoute: RegisterAPIRouteFn = ( path: `${LENS_VIS_API_PATH}/{id}`, access: LENS_API_ACCESS, summary: 'Get visualization', - description: 'Get a visualization from id.', + description: 'Returns a single Lens visualization by its ID.', options: { tags: [LENS_API_TAG], availability: { stability: 'experimental', + since: '9.4.0', }, }, security: { diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/common.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/common.ts index 8ae59877f33e5..298eaf7f615e4 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/common.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/common.ts @@ -9,16 +9,14 @@ import { schema } from '@kbn/config-schema'; import { lensApiStateSchema } from '@kbn/lens-embeddable-utils'; import { asCodeMetaSchema } from '@kbn/as-code-shared-schemas'; -import { lensCommonSavedObjectSchemaV2 } from '../../../../content_management'; - -const savedObjectProps = lensCommonSavedObjectSchemaV2.getPropSchemas(); - /** * The Lens response item returned from the server */ export const lensResponseItemSchema = schema.object( { - id: savedObjectProps.id, + id: schema.string({ + meta: { description: 'Unique identifier for the visualization.' }, + }), data: lensApiStateSchema, meta: asCodeMetaSchema, }, diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/create.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/create.ts index cf6a964677a2e..5988555513af5 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/create.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/create.ts @@ -8,13 +8,20 @@ import { schema } from '@kbn/config-schema'; import { lensApiStateSchema } from '@kbn/lens-embeddable-utils/config_builder'; -import { lensCMCreateOptionsSchema } from '../../../../content_management'; -import { pickFromObjectSchema } from '../../../../utils'; import { lensResponseItemSchema } from './common'; +// Inline schema so that the description renders in the generated OAS. +// The shared lensCMCreateOptionsSchema doesn't carry descriptions. export const lensCreateRequestQuerySchema = schema.object( { - ...pickFromObjectSchema(lensCMCreateOptionsSchema.getPropSchemas(), ['overwrite']), + overwrite: schema.maybe( + schema.boolean({ + meta: { + description: + 'When `true`, replaces an existing visualization that has the same ID. Defaults to `false`.', + }, + }) + ), }, { unknowns: 'forbid' } ); diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/delete.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/delete.ts index 1efe4be16e65e..d40c9fe0fe26f 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/delete.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/delete.ts @@ -11,7 +11,7 @@ export const lensDeleteRequestParamsSchema = schema.object( { id: schema.string({ meta: { - description: 'The id of a visualization.', + description: 'The visualization identifier, as returned by the create or search endpoints.', }, }), }, diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/get.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/get.ts index bd10a8994b51c..74a297250e4ea 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/get.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/get.ts @@ -13,7 +13,7 @@ export const lensGetRequestParamsSchema = schema.object( { id: schema.string({ meta: { - description: 'The id of a visualization.', + description: 'The visualization identifier, as returned by the create or search endpoints.', }, }), }, diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/search.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/search.ts index 91b882b505024..59f9de6824c90 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/search.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/search.ts @@ -6,31 +6,47 @@ */ import { schema } from '@kbn/config-schema'; -import { searchOptionsSchemas } from '@kbn/content-management-utils'; -import { lensCMSearchOptionsSchema } from '../../../../content_management'; import { lensResponseItemSchema } from './common'; +// Request query and response meta fields are defined inline so that descriptions +// render in the generated OAS. The shared searchOptionsSchemas don't carry +// descriptions, and .extendsDeep() on maybe()-wrapped schemas doesn't propagate +// them into the OAS output. export const lensSearchRequestQuerySchema = schema.object({ - fields: lensCMSearchOptionsSchema.getPropSchemas().fields, - search_fields: lensCMSearchOptionsSchema.getPropSchemas().searchFields, + fields: schema.maybe( + schema.arrayOf(schema.string(), { + meta: { + description: + 'Attributes to include in each result. Defaults to all fields. Valid values: `title`, `description`, `visualizationType`, `state`, `version`.', + }, + }) + ), + search_fields: schema.maybe( + schema.oneOf([schema.string(), schema.arrayOf(schema.string())], { + meta: { + description: + 'Attributes to search within when `query` is set. Valid values: `title`, `description`, `visualizationType`. Defaults to `title` and `description`.', + }, + }) + ), query: schema.maybe( schema.string({ meta: { - description: 'The text to search for Lens visualizations', + description: 'Text to match against `search_fields`.', }, }) ), page: schema.number({ meta: { - description: 'Specifies the current page number of the paginated result.', + description: 'Page number.', }, min: 1, defaultValue: 1, }), per_page: schema.number({ meta: { - description: 'Maximum number of Lens visualizations included in a single response', + description: 'Results per page.', }, defaultValue: 20, min: 1, @@ -40,9 +56,19 @@ export const lensSearchRequestQuerySchema = schema.object({ const lensSearchResponseMetaSchema = schema.object( { - page: searchOptionsSchemas.page, - per_page: searchOptionsSchemas.perPage, - total: schema.number(), // TODO use shared definition + page: schema.maybe( + schema.number({ + meta: { description: 'Current page number.' }, + }) + ), + per_page: schema.maybe( + schema.number({ + meta: { description: 'Number of results per page.' }, + }) + ), + total: schema.number({ + meta: { description: 'Total number of matching visualizations.' }, + }), }, { unknowns: 'forbid' } ); diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/update.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/update.ts index 287e753a86510..9b7397c48ab15 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/update.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/update.ts @@ -14,7 +14,7 @@ export const lensUpdateRequestParamsSchema = schema.object( { id: schema.string({ meta: { - description: 'The id of a visualization.', + description: 'The visualization identifier, as returned by the create or search endpoints.', }, }), }, diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/search.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/search.ts index d886e8b894943..fc549f11b798f 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/search.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/search.ts @@ -28,11 +28,12 @@ export const registerLensVisualizationsSearchAPIRoute: RegisterAPIRouteFn = ( path: LENS_VIS_API_PATH, access: LENS_API_ACCESS, summary: 'Search visualizations', - description: 'Get list of visualizations.', + description: 'Returns a paginated list of Lens visualizations matching the optional `query` text.', options: { tags: [LENS_API_TAG], availability: { stability: 'experimental', + since: '9.4.0', }, }, security: { diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/update.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/update.ts index 269a1028b3f61..938d9ce5fc709 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/update.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/update.ts @@ -37,13 +37,20 @@ export const registerLensVisualizationsUpdateAPIRoute: RegisterAPIRouteFn = ( const updateRoute = router.put({ path: `${LENS_VIS_API_PATH}/{id}`, access: LENS_API_ACCESS, - summary: 'Create or update visualization', - description: - 'Create or update a visualization with the given id. When no visualization exists for the id, one is created.', + summary: 'Update visualization', + description: [ + 'Replaces the full configuration of an existing Lens visualization. Partial updates are not supported.', + 'To make incremental changes, retrieve the visualization first, modify the fields you need, then send the complete object back.', + '', + 'If no visualization exists with the specified ID, a new one is created.', + '', + 'ES|QL visualizations cannot be updated through this endpoint.', + ].join('\n'), options: { tags: [LENS_API_TAG], availability: { stability: 'experimental', + since: '9.4.0', }, }, security: { From 33221f16e7a2b6a44497554e8240fe8c54a3ef55 Mon Sep 17 00:00:00 2001 From: Florent Le Borgne Date: Tue, 14 Apr 2026 19:23:15 +0200 Subject: [PATCH 2/5] [Docs][Visualizations API] Move field descriptions to shared schemas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of inlining schemas to add descriptions, add descriptions directly to the shared schemas in @kbn/content-management-utils so all API consumers benefit (Lens, Dashboards, SavedSearch, DataViews, Maps, etc.): - searchOptionsSchemas.fields, .searchFields, .page, .perPage - createOptionsSchemas.overwrite Restore the original import structure in schema/search.ts and schema/create.ts — both files now reference the shared schemas again with no structural changes. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .../src/schema.ts | 25 ++++++++++--- .../routes/visualizations/schema/create.ts | 13 ++----- .../routes/visualizations/schema/search.ts | 36 ++++--------------- 3 files changed, 29 insertions(+), 45 deletions(-) diff --git a/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts b/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts index b82b34e2f0834..74e3a546d32e1 100644 --- a/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts +++ b/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts @@ -77,7 +77,14 @@ export const objectTypeToGetResultSchema = >(soSchema: export const createOptionsSchemas = { id: schema.maybe(schema.string()), references: schema.maybe(referencesSchema), - overwrite: schema.maybe(schema.boolean()), + overwrite: schema.maybe( + schema.boolean({ + meta: { + description: + 'When `true`, replaces an existing saved object with the same ID. Defaults to `false`.', + }, + }) + ), version: schema.maybe(schema.string()), refresh: schema.maybe(schema.boolean()), initialNamespaces: schema.maybe(schema.arrayOf(schema.string())), @@ -88,13 +95,21 @@ export const schemaAndOr = schema.oneOf([schema.literal('AND'), schema.literal(' // its recommended to create a subset of this schema for stricter validation export const searchOptionsSchemas = { - page: schema.maybe(schema.number()), - perPage: schema.maybe(schema.number()), + page: schema.maybe(schema.number({ meta: { description: 'Page number.' } })), + perPage: schema.maybe(schema.number({ meta: { description: 'Number of results per page.' } })), sortField: schema.maybe(schema.string()), sortOrder: schema.maybe(schema.oneOf([schema.literal('asc'), schema.literal('desc')])), - fields: schema.maybe(schema.arrayOf(schema.string())), + fields: schema.maybe( + schema.arrayOf(schema.string(), { + meta: { description: 'Fields to include in each result. When omitted, all fields are returned.' }, + }) + ), search: schema.maybe(schema.string()), - searchFields: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])), + searchFields: schema.maybe( + schema.oneOf([schema.string(), schema.arrayOf(schema.string())], { + meta: { description: 'Fields to search within. Has no effect when no search query is specified.' }, + }) + ), rootSearchFields: schema.maybe(schema.arrayOf(schema.string())), hasReference: schema.maybe(schema.oneOf([referenceSchema, schema.arrayOf(referenceSchema)])), diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/create.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/create.ts index 5988555513af5..cf6a964677a2e 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/create.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/create.ts @@ -8,20 +8,13 @@ import { schema } from '@kbn/config-schema'; import { lensApiStateSchema } from '@kbn/lens-embeddable-utils/config_builder'; +import { lensCMCreateOptionsSchema } from '../../../../content_management'; +import { pickFromObjectSchema } from '../../../../utils'; import { lensResponseItemSchema } from './common'; -// Inline schema so that the description renders in the generated OAS. -// The shared lensCMCreateOptionsSchema doesn't carry descriptions. export const lensCreateRequestQuerySchema = schema.object( { - overwrite: schema.maybe( - schema.boolean({ - meta: { - description: - 'When `true`, replaces an existing visualization that has the same ID. Defaults to `false`.', - }, - }) - ), + ...pickFromObjectSchema(lensCMCreateOptionsSchema.getPropSchemas(), ['overwrite']), }, { unknowns: 'forbid' } ); diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/search.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/search.ts index 59f9de6824c90..e6cff364204a4 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/search.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/search.ts @@ -6,30 +6,14 @@ */ import { schema } from '@kbn/config-schema'; +import { searchOptionsSchemas } from '@kbn/content-management-utils'; +import { lensCMSearchOptionsSchema } from '../../../../content_management'; import { lensResponseItemSchema } from './common'; -// Request query and response meta fields are defined inline so that descriptions -// render in the generated OAS. The shared searchOptionsSchemas don't carry -// descriptions, and .extendsDeep() on maybe()-wrapped schemas doesn't propagate -// them into the OAS output. export const lensSearchRequestQuerySchema = schema.object({ - fields: schema.maybe( - schema.arrayOf(schema.string(), { - meta: { - description: - 'Attributes to include in each result. Defaults to all fields. Valid values: `title`, `description`, `visualizationType`, `state`, `version`.', - }, - }) - ), - search_fields: schema.maybe( - schema.oneOf([schema.string(), schema.arrayOf(schema.string())], { - meta: { - description: - 'Attributes to search within when `query` is set. Valid values: `title`, `description`, `visualizationType`. Defaults to `title` and `description`.', - }, - }) - ), + fields: lensCMSearchOptionsSchema.getPropSchemas().fields, + search_fields: lensCMSearchOptionsSchema.getPropSchemas().searchFields, query: schema.maybe( schema.string({ meta: { @@ -56,16 +40,8 @@ export const lensSearchRequestQuerySchema = schema.object({ const lensSearchResponseMetaSchema = schema.object( { - page: schema.maybe( - schema.number({ - meta: { description: 'Current page number.' }, - }) - ), - per_page: schema.maybe( - schema.number({ - meta: { description: 'Number of results per page.' }, - }) - ), + page: searchOptionsSchemas.page, + per_page: searchOptionsSchemas.perPage, total: schema.number({ meta: { description: 'Total number of matching visualizations.' }, }), From 6aec1472ace4cb342645d8b9f4ffa4ee11c952fd Mon Sep 17 00:00:00 2001 From: Florent Le Borgne Date: Tue, 14 Apr 2026 19:34:47 +0200 Subject: [PATCH 3/5] [Docs][Visualizations API] Add id description to savedObjectSchema, restore import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add generic 'Unique identifier.' description to savedObjectSchema.id in @kbn/content-management-utils so all content management consumers benefit. Revert schema/common.ts to reference savedObjectProps.id again — no net import changes from main. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .../shared/kbn-content-management-utils/src/schema.ts | 2 +- .../server/api/routes/visualizations/schema/common.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts b/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts index 74e3a546d32e1..f0d98d77dd671 100644 --- a/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts +++ b/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts @@ -31,7 +31,7 @@ export const referencesSchema = schema.arrayOf(referenceSchema); export const savedObjectSchema = >(attributesSchema: T) => schema.object( { - id: schema.string(), + id: schema.string({ meta: { description: 'Unique identifier.' } }), type: schema.string(), version: schema.maybe(schema.string()), createdAt: schema.maybe(schema.string()), diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/common.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/common.ts index 298eaf7f615e4..8ae59877f33e5 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/common.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/schema/common.ts @@ -9,14 +9,16 @@ import { schema } from '@kbn/config-schema'; import { lensApiStateSchema } from '@kbn/lens-embeddable-utils'; import { asCodeMetaSchema } from '@kbn/as-code-shared-schemas'; +import { lensCommonSavedObjectSchemaV2 } from '../../../../content_management'; + +const savedObjectProps = lensCommonSavedObjectSchemaV2.getPropSchemas(); + /** * The Lens response item returned from the server */ export const lensResponseItemSchema = schema.object( { - id: schema.string({ - meta: { description: 'Unique identifier for the visualization.' }, - }), + id: savedObjectProps.id, data: lensApiStateSchema, meta: asCodeMetaSchema, }, From cbe79b8fffb6989fdf9d45853b2d3f999048d201 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 14 Apr 2026 18:38:11 +0000 Subject: [PATCH 4/5] Changes from node scripts/eslint_all_files --no-cache --fix --- .../shared/kbn-content-management-utils/src/schema.ts | 8 ++++++-- .../lens/server/api/routes/visualizations/search.ts | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts b/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts index f0d98d77dd671..6b4caa903d3cc 100644 --- a/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts +++ b/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts @@ -101,13 +101,17 @@ export const searchOptionsSchemas = { sortOrder: schema.maybe(schema.oneOf([schema.literal('asc'), schema.literal('desc')])), fields: schema.maybe( schema.arrayOf(schema.string(), { - meta: { description: 'Fields to include in each result. When omitted, all fields are returned.' }, + meta: { + description: 'Fields to include in each result. When omitted, all fields are returned.', + }, }) ), search: schema.maybe(schema.string()), searchFields: schema.maybe( schema.oneOf([schema.string(), schema.arrayOf(schema.string())], { - meta: { description: 'Fields to search within. Has no effect when no search query is specified.' }, + meta: { + description: 'Fields to search within. Has no effect when no search query is specified.', + }, }) ), rootSearchFields: schema.maybe(schema.arrayOf(schema.string())), diff --git a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/search.ts b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/search.ts index fc549f11b798f..7d265274a5807 100644 --- a/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/search.ts +++ b/x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/search.ts @@ -28,7 +28,8 @@ export const registerLensVisualizationsSearchAPIRoute: RegisterAPIRouteFn = ( path: LENS_VIS_API_PATH, access: LENS_API_ACCESS, summary: 'Search visualizations', - description: 'Returns a paginated list of Lens visualizations matching the optional `query` text.', + description: + 'Returns a paginated list of Lens visualizations matching the optional `query` text.', options: { tags: [LENS_API_TAG], availability: { From 09797835456f48e404effeb4028f5436127dd632 Mon Sep 17 00:00:00 2001 From: Florent Le Borgne Date: Thu, 16 Apr 2026 20:50:41 +0200 Subject: [PATCH 5/5] [Docs][Visualizations API] Revert content-management-utils description changes Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .../src/schema.ts | 31 ++++--------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts b/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts index 6b4caa903d3cc..b82b34e2f0834 100644 --- a/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts +++ b/src/platform/packages/shared/kbn-content-management-utils/src/schema.ts @@ -31,7 +31,7 @@ export const referencesSchema = schema.arrayOf(referenceSchema); export const savedObjectSchema = >(attributesSchema: T) => schema.object( { - id: schema.string({ meta: { description: 'Unique identifier.' } }), + id: schema.string(), type: schema.string(), version: schema.maybe(schema.string()), createdAt: schema.maybe(schema.string()), @@ -77,14 +77,7 @@ export const objectTypeToGetResultSchema = >(soSchema: export const createOptionsSchemas = { id: schema.maybe(schema.string()), references: schema.maybe(referencesSchema), - overwrite: schema.maybe( - schema.boolean({ - meta: { - description: - 'When `true`, replaces an existing saved object with the same ID. Defaults to `false`.', - }, - }) - ), + overwrite: schema.maybe(schema.boolean()), version: schema.maybe(schema.string()), refresh: schema.maybe(schema.boolean()), initialNamespaces: schema.maybe(schema.arrayOf(schema.string())), @@ -95,25 +88,13 @@ export const schemaAndOr = schema.oneOf([schema.literal('AND'), schema.literal(' // its recommended to create a subset of this schema for stricter validation export const searchOptionsSchemas = { - page: schema.maybe(schema.number({ meta: { description: 'Page number.' } })), - perPage: schema.maybe(schema.number({ meta: { description: 'Number of results per page.' } })), + page: schema.maybe(schema.number()), + perPage: schema.maybe(schema.number()), sortField: schema.maybe(schema.string()), sortOrder: schema.maybe(schema.oneOf([schema.literal('asc'), schema.literal('desc')])), - fields: schema.maybe( - schema.arrayOf(schema.string(), { - meta: { - description: 'Fields to include in each result. When omitted, all fields are returned.', - }, - }) - ), + fields: schema.maybe(schema.arrayOf(schema.string())), search: schema.maybe(schema.string()), - searchFields: schema.maybe( - schema.oneOf([schema.string(), schema.arrayOf(schema.string())], { - meta: { - description: 'Fields to search within. Has no effect when no search query is specified.', - }, - }) - ), + searchFields: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])), rootSearchFields: schema.maybe(schema.arrayOf(schema.string())), hasReference: schema.maybe(schema.oneOf([referenceSchema, schema.arrayOf(referenceSchema)])),