['access'], undefined>;
@@ -342,6 +350,11 @@ export interface AddVersionOpts {
options?: {
deprecated?: RouteDeprecationInfo;
+ /**
+ * @public
+ * {@inheritdoc RouteConfigOptions['oasOperationObject']}
+ */
+ oasOperationObject?: RouteConfigOptions['oasOperationObject'];
};
}
diff --git a/src/platform/packages/shared/kbn-router-to-openapispec/src/generate_oas.test.ts b/src/platform/packages/shared/kbn-router-to-openapispec/src/generate_oas.test.ts
index 603010926a515..0bcc83ea0f4a8 100644
--- a/src/platform/packages/shared/kbn-router-to-openapispec/src/generate_oas.test.ts
+++ b/src/platform/packages/shared/kbn-router-to-openapispec/src/generate_oas.test.ts
@@ -8,6 +8,7 @@
*/
import { schema, Type } from '@kbn/config-schema';
+import { get } from 'lodash';
import { generateOpenApiDocument } from './generate_oas';
import { createTestRouters, createRouter, createVersionedRouter } from './generate_oas.test.util';
import {
@@ -23,7 +24,7 @@ interface RecursiveType {
describe('generateOpenApiDocument', () => {
describe('@kbn/config-schema', () => {
- it('generates the expected OpenAPI document for the shared schema', () => {
+ it('generates the expected OpenAPI document for the shared schema', async () => {
const [routers, versionedRouters] = createTestRouters({
routers: {
testRouter: {
@@ -34,7 +35,7 @@ describe('generateOpenApiDocument', () => {
bodySchema: createSharedConfigSchema(),
});
expect(
- generateOpenApiDocument(
+ await generateOpenApiDocument(
{
routers,
versionedRouters,
@@ -48,7 +49,7 @@ describe('generateOpenApiDocument', () => {
).toEqual(sharedOas);
});
- it('generates the expected OpenAPI document', () => {
+ it('generates the expected OpenAPI document', async () => {
const [routers, versionedRouters] = createTestRouters({
routers: {
testRouter: {
@@ -80,7 +81,7 @@ describe('generateOpenApiDocument', () => {
},
});
expect(
- generateOpenApiDocument(
+ await generateOpenApiDocument(
{
routers,
versionedRouters,
@@ -94,7 +95,7 @@ describe('generateOpenApiDocument', () => {
).toMatchSnapshot();
});
- it('generates references in the expected format', () => {
+ it('generates references in the expected format', async () => {
const sharedIdSchema = schema.string({ minLength: 1, meta: { description: 'test' } });
const sharedNameSchema = schema.string({ minLength: 1 });
const otherSchema = schema.object(
@@ -102,7 +103,7 @@ describe('generateOpenApiDocument', () => {
{ meta: { id: 'foo' } }
);
expect(
- generateOpenApiDocument(
+ await generateOpenApiDocument(
{
routers: [
createRouter({
@@ -139,7 +140,7 @@ describe('generateOpenApiDocument', () => {
).toMatchSnapshot();
});
- it('handles recursive schemas', () => {
+ it('handles recursive schemas', async () => {
const id = 'recursive';
const recursiveSchema: Type = schema.object(
{
@@ -149,7 +150,7 @@ describe('generateOpenApiDocument', () => {
{ meta: { id } }
);
expect(
- generateOpenApiDocument(
+ await generateOpenApiDocument(
{
routers: [
createRouter({
@@ -187,7 +188,7 @@ describe('generateOpenApiDocument', () => {
});
describe('Zod', () => {
- it('generates the expected OpenAPI document for the shared schema', () => {
+ it('generates the expected OpenAPI document for the shared schema', async () => {
const [routers, versionedRouters] = createTestRouters({
routers: { testRouter: { routes: [{ method: 'get' }, { method: 'post' }] } },
versionedRouters: { testVersionedRouter: { routes: [{}] } },
@@ -195,7 +196,7 @@ describe('generateOpenApiDocument', () => {
});
expect(
- generateOpenApiDocument(
+ await generateOpenApiDocument(
{
routers,
versionedRouters,
@@ -211,9 +212,9 @@ describe('generateOpenApiDocument', () => {
});
describe('unknown schema/validation', () => {
- it('produces the expected output', () => {
+ it('produces the expected output', async () => {
expect(
- generateOpenApiDocument(
+ await generateOpenApiDocument(
{
routers: [
createRouter({
@@ -275,7 +276,7 @@ describe('generateOpenApiDocument', () => {
});
describe('tags', () => {
- it('handles tags as expected', () => {
+ it('handles tags as expected', async () => {
const [routers, versionedRouters] = createTestRouters({
routers: {
testRouter1: {
@@ -314,7 +315,7 @@ describe('generateOpenApiDocument', () => {
},
},
});
- const result = generateOpenApiDocument(
+ const result = await generateOpenApiDocument(
{
routers,
versionedRouters,
@@ -337,7 +338,7 @@ describe('generateOpenApiDocument', () => {
});
describe('availability', () => {
- it('creates the expected availability entries', () => {
+ it('creates the expected availability entries', async () => {
const [routers, versionedRouters] = createTestRouters({
routers: {
testRouter1: {
@@ -391,7 +392,7 @@ describe('generateOpenApiDocument', () => {
},
},
});
- const result = generateOpenApiDocument(
+ const result = await generateOpenApiDocument(
{
routers,
versionedRouters,
@@ -434,4 +435,84 @@ describe('generateOpenApiDocument', () => {
});
});
});
+
+ it('merges operation objects', async () => {
+ const oasOperationObject = () => ({
+ requestBody: {
+ content: {
+ 'application/json': {
+ examples: {
+ fooExample: {
+ value: 999,
+ },
+ },
+ },
+ },
+ },
+ });
+ const [routers, versionedRouters] = createTestRouters({
+ routers: {
+ testRouter: {
+ routes: [
+ {
+ method: 'get',
+ options: {
+ access: 'public',
+ oasOperationObject,
+ },
+ },
+ { method: 'post' },
+ ],
+ },
+ },
+ versionedRouters: {
+ testVersionedRouter: {
+ routes: [
+ {
+ options: {
+ access: 'public',
+ },
+ },
+ ],
+ },
+ },
+ bodySchema: createSharedConfigSchema(),
+ });
+
+ versionedRouters[0].getRoutes()[0].handlers[0].options!.options!.oasOperationObject =
+ oasOperationObject;
+
+ const oas = await generateOpenApiDocument(
+ { routers, versionedRouters },
+ {
+ title: 'test',
+ baseUrl: 'https://test.oas',
+ version: '99.99.99',
+ }
+ );
+
+ expect(
+ get(oas, [
+ 'paths',
+ '/foo/{id}/{path}',
+ 'get',
+ 'requestBody',
+ 'content',
+ 'application/json',
+ 'examples',
+ ])
+ ).toEqual({
+ fooExample: {
+ value: 999,
+ },
+ });
+
+ expect(
+ get(oas, ['paths', '/bar', 'get', 'requestBody', 'content', 'application/json', 'examples'])
+ ).toEqual({
+ fooExample: {
+ value: 999,
+ },
+ });
+ });
});
diff --git a/src/platform/packages/shared/kbn-router-to-openapispec/src/generate_oas.ts b/src/platform/packages/shared/kbn-router-to-openapispec/src/generate_oas.ts
index d16cdd14953a9..57dded0a57922 100644
--- a/src/platform/packages/shared/kbn-router-to-openapispec/src/generate_oas.ts
+++ b/src/platform/packages/shared/kbn-router-to-openapispec/src/generate_oas.ts
@@ -39,10 +39,10 @@ export interface GenerateOpenApiDocumentOptions {
filters?: GenerateOpenApiDocumentOptionsFilters;
}
-export const generateOpenApiDocument = (
+export const generateOpenApiDocument = async (
appRouters: { routers: Router[]; versionedRouters: CoreVersionedRouter[] },
opts: GenerateOpenApiDocumentOptions
-): OpenAPIV3.Document => {
+): Promise => {
let { filters = { access: 'public' } } = opts;
if (filters.access === 'public' && !filters.version) {
filters = { ...filters, version: SERVERLESS_VERSION_2023_10_31 };
@@ -51,11 +51,11 @@ export const generateOpenApiDocument = (
const paths: OpenAPIV3.PathsObject = {};
const getOpId = createOpIdGenerator();
for (const router of appRouters.routers) {
- const result = processRouter(router, converter, getOpId, filters);
+ const result = await processRouter(router, converter, getOpId, filters);
Object.assign(paths, result.paths);
}
for (const router of appRouters.versionedRouters) {
- const result = processVersionedRouter(router, converter, getOpId, filters);
+ const result = await processVersionedRouter(router, converter, getOpId, filters);
Object.assign(paths, result.paths);
}
const tags = buildGlobalTags(paths, opts.tags);
diff --git a/src/platform/packages/shared/kbn-router-to-openapispec/src/merge_operation.ts b/src/platform/packages/shared/kbn-router-to-openapispec/src/merge_operation.ts
new file mode 100644
index 0000000000000..b1f5ba0d63464
--- /dev/null
+++ b/src/platform/packages/shared/kbn-router-to-openapispec/src/merge_operation.ts
@@ -0,0 +1,25 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the "Elastic License
+ * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
+ * Public License v 1"; you may not use this file except in compliance with, at
+ * your election, the "Elastic License 2.0", the "GNU Affero General Public
+ * License v3.0 only", or the "Server Side Public License, v 1".
+ */
+
+import type { OpenAPIV3 } from 'openapi-types';
+import type { DeepPartial } from '@kbn/utility-types';
+import { dereference } from '@apidevtools/json-schema-ref-parser';
+import deepMerge from 'deepmerge';
+import type { CustomOperationObject } from './type';
+
+export async function mergeOperation(
+ pathToSpecOrSpec: string | DeepPartial,
+ operation: CustomOperationObject
+) {
+ if (typeof pathToSpecOrSpec === 'string') {
+ Object.assign(operation, deepMerge(operation, await dereference(pathToSpecOrSpec)));
+ } else {
+ Object.assign(operation, deepMerge(operation, pathToSpecOrSpec));
+ }
+}
diff --git a/src/platform/packages/shared/kbn-router-to-openapispec/src/process_router.test.ts b/src/platform/packages/shared/kbn-router-to-openapispec/src/process_router.test.ts
index a7bcfc7506485..3c3d568ce8c95 100644
--- a/src/platform/packages/shared/kbn-router-to-openapispec/src/process_router.test.ts
+++ b/src/platform/packages/shared/kbn-router-to-openapispec/src/process_router.test.ts
@@ -148,23 +148,23 @@ describe('processRouter', () => {
],
} as unknown as Router;
- it('only provides routes for version 2023-10-31', () => {
- const result1 = processRouter(testRouter, new OasConverter(), createOpIdGenerator(), {
+ it('only provides routes for version 2023-10-31', async () => {
+ const result1 = await processRouter(testRouter, new OasConverter(), createOpIdGenerator(), {
version: '2023-10-31',
access: 'public',
});
expect(Object.keys(result1.paths!)).toHaveLength(5);
- const result2 = processRouter(testRouter, new OasConverter(), createOpIdGenerator(), {
+ const result2 = await processRouter(testRouter, new OasConverter(), createOpIdGenerator(), {
version: '2024-10-31',
access: 'public',
});
expect(Object.keys(result2.paths!)).toHaveLength(0);
});
- it('updates description with privileges required', () => {
- const result = processRouter(testRouter, new OasConverter(), createOpIdGenerator(), {
+ it('updates description with privileges required', async () => {
+ const result = await processRouter(testRouter, new OasConverter(), createOpIdGenerator(), {
version: '2023-10-31',
access: 'public',
});
diff --git a/src/platform/packages/shared/kbn-router-to-openapispec/src/process_router.ts b/src/platform/packages/shared/kbn-router-to-openapispec/src/process_router.ts
index f47888808772f..0803f0d3bad05 100644
--- a/src/platform/packages/shared/kbn-router-to-openapispec/src/process_router.ts
+++ b/src/platform/packages/shared/kbn-router-to-openapispec/src/process_router.ts
@@ -28,8 +28,9 @@ import {
import type { GenerateOpenApiDocumentOptionsFilters } from './generate_oas';
import type { CustomOperationObject, InternalRouterRoute } from './type';
import { extractAuthzDescription } from './extract_authz_description';
+import { mergeOperation } from './merge_operation';
-export const processRouter = (
+export const processRouter = async (
appRouter: Router,
converter: OasConverter,
getOpId: GetOpId,
@@ -99,6 +100,10 @@ export const processRouter = (
setXState(route.options.availability, operation);
+ if (route.options.oasOperationObject) {
+ await mergeOperation(route.options.oasOperationObject(), operation);
+ }
+
const path: OpenAPIV3.PathItemObject = {
[route.method]: operation,
};
diff --git a/src/platform/packages/shared/kbn-router-to-openapispec/src/process_versioned_router.test.ts b/src/platform/packages/shared/kbn-router-to-openapispec/src/process_versioned_router.test.ts
index af426b5f0c4f9..394e8e7f462a6 100644
--- a/src/platform/packages/shared/kbn-router-to-openapispec/src/process_versioned_router.test.ts
+++ b/src/platform/packages/shared/kbn-router-to-openapispec/src/process_versioned_router.test.ts
@@ -121,8 +121,8 @@ describe('extractVersionedResponses', () => {
});
describe('processVersionedRouter', () => {
- it('correctly extracts the version based on the version filter', () => {
- const baseCase = processVersionedRouter(
+ it('correctly extracts the version based on the version filter', async () => {
+ const baseCase = await processVersionedRouter(
{ getRoutes: () => [createTestRoute()] } as unknown as CoreVersionedRouter,
new OasConverter(),
createOpIdGenerator(),
@@ -133,7 +133,7 @@ describe('processVersionedRouter', () => {
'application/test+json',
]);
- const filteredCase = processVersionedRouter(
+ const filteredCase = await processVersionedRouter(
{ getRoutes: () => [createTestRoute()] } as unknown as CoreVersionedRouter,
new OasConverter(),
createOpIdGenerator(),
@@ -144,8 +144,8 @@ describe('processVersionedRouter', () => {
]);
});
- it('correctly updates the authz description for routes that require privileges', () => {
- const results = processVersionedRouter(
+ it('correctly updates the authz description for routes that require privileges', async () => {
+ const results = await processVersionedRouter(
{ getRoutes: () => [createTestRoute()] } as unknown as CoreVersionedRouter,
new OasConverter(),
createOpIdGenerator(),
diff --git a/src/platform/packages/shared/kbn-router-to-openapispec/src/process_versioned_router.ts b/src/platform/packages/shared/kbn-router-to-openapispec/src/process_versioned_router.ts
index 7c16e5673cebb..c8bfd1ddb1c03 100644
--- a/src/platform/packages/shared/kbn-router-to-openapispec/src/process_versioned_router.ts
+++ b/src/platform/packages/shared/kbn-router-to-openapispec/src/process_versioned_router.ts
@@ -31,8 +31,9 @@ import {
GetOpId,
} from './util';
import { isReferenceObject } from './oas_converter/common';
+import { mergeOperation } from './merge_operation';
-export const processVersionedRouter = (
+export const processVersionedRouter = async (
appRouter: CoreVersionedRouter,
converter: OasConverter,
getOpId: GetOpId,
@@ -130,6 +131,10 @@ export const processVersionedRouter = (
setXState(route.options.options?.availability, operation);
+ if (handler.options.options?.oasOperationObject) {
+ await mergeOperation(handler.options.options.oasOperationObject(), operation);
+ }
+
const path: OpenAPIV3.PathItemObject = {
[route.method]: operation,
};
diff --git a/src/platform/packages/shared/kbn-router-to-openapispec/tsconfig.json b/src/platform/packages/shared/kbn-router-to-openapispec/tsconfig.json
index ead53f114322d..8b942fbf3b7bb 100644
--- a/src/platform/packages/shared/kbn-router-to-openapispec/tsconfig.json
+++ b/src/platform/packages/shared/kbn-router-to-openapispec/tsconfig.json
@@ -19,5 +19,6 @@
"@kbn/config-schema",
"@kbn/zod",
"@kbn/zod-helpers",
+ "@kbn/utility-types",
]
}
diff --git a/src/platform/packages/shared/kbn-server-route-repository/src/register_routes.ts b/src/platform/packages/shared/kbn-server-route-repository/src/register_routes.ts
index f322345399d11..899961a3e2bfc 100644
--- a/src/platform/packages/shared/kbn-server-route-repository/src/register_routes.ts
+++ b/src/platform/packages/shared/kbn-server-route-repository/src/register_routes.ts
@@ -193,7 +193,6 @@ export function registerRoutes>({
access,
summary: options.summary,
description: options.description,
- // @ts-expect-error we are essentially calling multiple methods at the same type so TS gets confused
options: omit(options, 'access', 'description', 'summary', 'deprecated', 'discontinued'),
security,
}).addVersion(
diff --git a/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_esql_rule_request.yaml b/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_esql_rule_request.yaml
new file mode 100644
index 0000000000000..0646699e8a41a
--- /dev/null
+++ b/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_esql_rule_request.yaml
@@ -0,0 +1,34 @@
+summary: Elasticsearch query rule (ES|QL)
+description: >
+ Create an Elasticsearch query rule that uses Elasticsearch Query Language (ES|QL) to define its query and a server log connector to send notifications.
+value:
+ name: my Elasticsearch query ESQL rule
+ params:
+ searchType: esqlQuery
+ esqlQuery:
+ esql: 'FROM kibana_sample_data_logs | KEEP bytes, clientip, host, geo.dest | where geo.dest != "GB" | STATS sumbytes = sum(bytes) by clientip, host | WHERE sumbytes > 5000 | SORT sumbytes desc | LIMIT 10'
+ timeField: "@timestamp"
+ timeWindowSize: 1
+ timeWindowUnit: d
+ size: 0
+ thresholdComparator: ">"
+ threshold:
+ - 0
+ consumer: stackAlerts
+ rule_type_id: .es-query
+ schedule:
+ interval: 1d
+ actions:
+ - group: query matched
+ id: d0db1fe0-78d6-11ee-9177-f7d404c8c945
+ params:
+ level: info
+ message: "Elasticsearch query rule '{{rule.name}}' is active:
+
+ - Value: {{context.value}}
+ - Conditions Met: {{context.conditions}} over {{rule.params.timeWindowSize}}{{rule.params.timeWindowUnit}}
+ - Timestamp: {{context.date}}
+ - Link: {{context.link}}"
+ frequency:
+ summary: false
+ notify_when: onActiveAlert
diff --git a/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_esql_rule_response.yaml b/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_esql_rule_response.yaml
new file mode 100644
index 0000000000000..fa4ebd0977674
--- /dev/null
+++ b/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_esql_rule_response.yaml
@@ -0,0 +1,58 @@
+summary: Elasticsearch query rule (ES|QL)
+description: The response for successfully creating an Elasticsearch query rule that uses Elasticsearch Query Language (ES|QL).
+value:
+ id: e0d62360-78e8-11ee-9177-f7d404c8c945
+ enabled: true
+ name: my Elasticsearch query ESQL rule
+ tags: []
+ rule_type_id: .es-query
+ consumer: stackAlerts
+ schedule:
+ interval: 1d
+ actions:
+ - group: query matched
+ id: d0db1fe0-78d6-11ee-9177-f7d404c8c945
+ params:
+ level: info
+ message: "Elasticsearch query rule '{{rule.name}}' is active:
+
+ - Value: {{context.value}}
+ - Conditions Met: {{context.conditions}} over {{rule.params.timeWindowSize}}{{rule.params.timeWindowUnit}}
+ - Timestamp: {{context.date}}
+ - Link: {{context.link}}"
+ connector_type_id: .server-log
+ frequency:
+ summary: false
+ notify_when: onActiveAlert
+ throttle: null
+ uuid: bfe370a3-531b-4855-bbe6-ad739f578844
+ params:
+ searchType: esqlQuery
+ esqlQuery:
+ esql: 'FROM kibana_sample_data_logs | keep bytes, clientip, host, geo.dest | WHERE geo.dest != "GB" | stats sumbytes = sum(bytes) by clientip, host | WHERE sumbytes > 5000 | sort sumbytes desc | limit 10'
+ timeField: "@timestamp"
+ timeWindowSize: 1
+ timeWindowUnit: d
+ size: 0
+ thresholdComparator: ">"
+ threshold:
+ - 0
+ excludeHitsFromPreviousRun": true,
+ aggType: count
+ groupBy: all
+ scheduled_task_id: e0d62360-78e8-11ee-9177-f7d404c8c945
+ created_by: elastic
+ updated_by: elastic",
+ created_at: '2023-11-01T19:00:10.453Z'
+ updated_at: '2023-11-01T19:00:10.453Z'
+ api_key_owner: elastic
+ api_key_created_by_user: false
+ throttle: null
+ mute_all: false
+ notify_when: null
+ muted_alert_ids: []
+ execution_status:
+ status: pending
+ last_execution_date: '2023-11-01T19:00:10.453Z'
+ revision: 0
+ running: false
diff --git a/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_kql_rule_request.yaml b/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_kql_rule_request.yaml
new file mode 100644
index 0000000000000..8b9af0129912e
--- /dev/null
+++ b/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_kql_rule_request.yaml
@@ -0,0 +1,24 @@
+summary: Elasticsearch query rule (KQL)
+description: Create an Elasticsearch query rule that uses Kibana query language (KQL).
+value:
+ consumer: alerts
+ name: my Elasticsearch query KQL rule
+ params:
+ aggType: count
+ excludeHitsFromPreviousRun: true
+ groupBy: all
+ searchConfiguration:
+ query:
+ query: '""geo.src : "US" ""'
+ language: kuery
+ index: 90943e30-9a47-11e8-b64d-95841ca0b247
+ searchType: searchSource
+ size: 100
+ threshold:
+ - 1000
+ thresholdComparator: ">"
+ timeWindowSize: 5
+ timeWindowUnit: m
+ rule_type_id: .es-query
+ schedule:
+ interval: 1m
diff --git a/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_kql_rule_response.yaml b/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_kql_rule_response.yaml
new file mode 100644
index 0000000000000..4ecaf503e082c
--- /dev/null
+++ b/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_kql_rule_response.yaml
@@ -0,0 +1,44 @@
+summary: Elasticsearch query rule (KQL)
+description: The response for successfully creating an Elasticsearch query rule that uses Kibana query language (KQL).
+value:
+ id: 7bd506d0-2284-11ee-8fad-6101956ced88
+ enabled: true
+ name: my Elasticsearch query KQL rule"
+ tags: []
+ rule_type_id: .es-query
+ consumer: alerts
+ schedule:
+ interval: 1m
+ actions: []
+ params:
+ searchConfiguration:
+ query:
+ query: '""geo.src : "US" ""'
+ language: kuery
+ index: 90943e30-9a47-11e8-b64d-95841ca0b247
+ searchType: searchSource
+ timeWindowSize: 5
+ timeWindowUnit: m
+ threshold:
+ - 1000
+ thresholdComparator: ">"
+ size: 100
+ aggType: count
+ groupBy: all
+ excludeHitsFromPreviousRun: true
+ created_by: elastic
+ updated_by: elastic
+ created_at: '2023-07-14T20:24:50.729Z'
+ updated_at: '2023-07-14T20:24:50.729Z'
+ api_key_owner: elastic
+ api_key_created_by_user: false
+ throttle: null
+ notify_when: null
+ mute_all: false
+ muted_alert_ids: []
+ scheduled_task_id: 7bd506d0-2284-11ee-8fad-6101956ced88
+ execution_status:
+ status: pending
+ last_execution_date: '2023-07-14T20:24:50.729Z'
+ revision: 0
+ running: false
\ No newline at end of file
diff --git a/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_rule_request.yaml b/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_rule_request.yaml
new file mode 100644
index 0000000000000..d021245ed7dff
--- /dev/null
+++ b/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_rule_request.yaml
@@ -0,0 +1,38 @@
+summary: Elasticsearch query rule (DSL)
+description: >
+ Create an Elasticsearch query rule that uses Elasticsearch query domain specific language (DSL) to define its query and a server log connector to send notifications.
+value:
+ actions:
+ - group: query matched
+ params:
+ level: info
+ message: "The system has detected {{alerts.new.count}} new, {{alerts.ongoing.count}} ongoing, and {{alerts.recovered.count}} recovered alerts."
+ id: fdbece50-406c-11ee-850e-c71febc4ca7f
+ frequency:
+ throttle: "1d"
+ summary: true
+ notify_when: onThrottleInterval
+ - group: recovered
+ params:
+ level: info
+ message: Recovered
+ id: fdbece50-406c-11ee-850e-c71febc4ca7f
+ frequency:
+ summary: false
+ notify_when: onActionGroupChange
+ consumer: alerts
+ name: my Elasticsearch query rule
+ params:
+ esQuery: '"""{"query":{"match_all" : {}}}"""'
+ index:
+ - kibana_sample_data_logs
+ size: 100
+ threshold:
+ - 100
+ thresholdComparator: ">"
+ timeField: "@timestamp"
+ timeWindowSize: 1
+ timeWindowUnit: d
+ rule_type_id: .es-query
+ schedule:
+ interval: 1d
\ No newline at end of file
diff --git a/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_rule_response.yaml b/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_rule_response.yaml
new file mode 100644
index 0000000000000..81a634959ca3c
--- /dev/null
+++ b/src/platform/packages/shared/response-ops/rule_params/es_query/create_es_query_rule_response.yaml
@@ -0,0 +1,65 @@
+summary: Elasticsearch query rule (DSL)
+description: The response for successfully creating an Elasticsearch query rule that uses Elasticsearch query domain specific language (DSL).
+value:
+ id: 58148c70-407f-11ee-850e-c71febc4ca7f
+ enabled: true
+ name: my Elasticsearch query rule
+ tags: []
+ rule_type_id: .es-query
+ consumer: alerts
+ schedule:
+ interval: 1d
+ actions:
+ - group: query matched
+ id: fdbece50-406c-11ee-850e-c71febc4ca7f
+ params:
+ level: info
+ message: "The system has detected {{alerts.new.count}} new, {{alerts.ongoing.count}} ongoing, and {{alerts.recovered.count}} recovered alerts."
+ connector_type_id: .server-log
+ frequency:
+ summary: true
+ notify_when: onThrottleInterval
+ throttle: "1d"
+ uuid: 53f3c2a3-e5d0-4cfa-af3b-6f0881385e78
+ - group: recovered
+ id: fdbece50-406c-11ee-850e-c71febc4ca7f
+ params:
+ level: info
+ message: Recovered
+ connector_type_id: .server-log
+ frequency:
+ summary: false
+ notify_when: onActionGroupChange
+ throttle: null
+ uuid: 2324e45b-c0df-45c7-9d70-4993e30be758
+ params:
+ thresholdComparator: ">"
+ timeWindowSize: 1
+ timeWindowUnit: d
+ threshold:
+ - 100
+ size: 100
+ timeField: "@timestamp"
+ index:
+ - kibana_sample_data_logs
+ esQuery: '"""{"query":{"match_all" : {}}}"""'
+ excludeHitsFromPreviousRun: true
+ aggType: count
+ groupBy: all
+ searchType: esQuery
+ scheduled_task_id: 58148c70-407f-11ee-850e-c71febc4ca7f
+ created_by: elastic
+ updated_by: elastic
+ created_at: '2023-08-22T00:03:38.263Z'
+ updated_at: '2023-08-22T00:03:38.263Z'
+ api_key_owner: elastic
+ api_key_created_by_user: false
+ throttle: null
+ mute_all: false
+ notify_when: null
+ muted_alert_ids: []
+ execution_status:
+ status: pending
+ last_execution_date: '2023-08-22T00:03:38.263Z'
+ revision: 0
+ running: false
\ No newline at end of file
diff --git a/src/platform/packages/shared/response-ops/rule_params/examples_create_rule_params.yaml b/src/platform/packages/shared/response-ops/rule_params/examples_create_rule_params.yaml
new file mode 100644
index 0000000000000..252b95c166978
--- /dev/null
+++ b/src/platform/packages/shared/response-ops/rule_params/examples_create_rule_params.yaml
@@ -0,0 +1,29 @@
+requestBody:
+ content:
+ application/json:
+ examples:
+ createEsQueryEsqlRuleRequest:
+ $ref: "./es_query/create_es_query_esql_rule_request.yaml"
+ createEsQueryRuleRequest:
+ $ref: "./es_query/create_es_query_rule_request.yaml"
+ createEsQueryKqlRuleRequest:
+ $ref: "./es_query/create_es_query_kql_rule_request.yaml"
+ createIndexThresholdRuleRequest:
+ $ref: "./index_threshold/create_index_threshold_rule_request.yaml"
+ createTrackingContainmentRuleRequest:
+ $ref: "./geo_containment/create_tracking_containment_rule_request.yaml"
+responses:
+ 200:
+ content:
+ application/json:
+ examples:
+ createEsQueryEsqlRuleResponse:
+ $ref: "./es_query/create_es_query_esql_rule_response.yaml"
+ createEsQueryRuleResponse:
+ $ref: "./es_query/create_es_query_rule_response.yaml"
+ createEsQueryKqlRuleResponse:
+ $ref: "./es_query/create_es_query_kql_rule_response.yaml"
+ createIndexThresholdRuleResponse:
+ $ref: "./index_threshold/create_index_threshold_rule_response.yaml"
+ createTrackingContainmentRuleResponse:
+ $ref: "./geo_containment/create_tracking_containment_rule_response.yaml"
\ No newline at end of file
diff --git a/src/platform/packages/shared/response-ops/rule_params/geo_containment/create_tracking_containment_rule_request.yaml b/src/platform/packages/shared/response-ops/rule_params/geo_containment/create_tracking_containment_rule_request.yaml
new file mode 100644
index 0000000000000..3a20a0bbe804a
--- /dev/null
+++ b/src/platform/packages/shared/response-ops/rule_params/geo_containment/create_tracking_containment_rule_request.yaml
@@ -0,0 +1,20 @@
+summary: Tracking containment rule
+description: >
+ Create a tracking containment rule that checks when an entity is contained or no longer contained within a boundary.
+value:
+ consumer: alerts
+ name: my tracking rule
+ params:
+ index: kibana_sample_data_logs
+ dateField": '@timestamp'
+ geoField: geo.coordinates
+ entity: agent.keyword
+ boundaryType: entireIndex
+ boundaryIndexTitle: boundary*
+ boundaryGeoField: location
+ boundaryNameField: name
+ indexId: 90943e30-9a47-11e8-b64d-95841ca0b247
+ boundaryIndexId: 0cd90abf-abe7-44c7-909a-f621bbbcfefc
+ rule_type_id: .geo-containment
+ schedule:
+ interval: 1h
\ No newline at end of file
diff --git a/src/platform/packages/shared/response-ops/rule_params/geo_containment/create_tracking_containment_rule_response.yaml b/src/platform/packages/shared/response-ops/rule_params/geo_containment/create_tracking_containment_rule_response.yaml
new file mode 100644
index 0000000000000..e68d2a484afc7
--- /dev/null
+++ b/src/platform/packages/shared/response-ops/rule_params/geo_containment/create_tracking_containment_rule_response.yaml
@@ -0,0 +1,51 @@
+summary: Tracking containment rule
+description: The response for successfully creating a tracking containment rule.
+value:
+ id: b6883f9d-5f70-4758-a66e-369d7c26012f
+ name: my tracking rule
+ tags: []
+ enabled: true
+ consumer: alerts
+ throttle: null
+ revision: 1
+ running: false
+ schedule:
+ interval: 1h
+ params:
+ index: kibana_sample_data_logs
+ dateField: '@timestamp'
+ geoField: geo.coordinates
+ entity: agent.keyword
+ boundaryType: entireIndex
+ boundaryIndexTitle: boundary*
+ boundaryGeoField: location
+ boundaryNameField: name
+ indexId: 90943e30-9a47-11e8-b64d-95841ca0b247
+ boundaryIndexId: 0cd90abf-abe7-44c7-909a-f621bbbcfefc
+ rule_type_id: .geo-containment
+ created_by: elastic
+ updated_by: elastic
+ created_at: '2024-02-14T19:52:55.920Z'
+ updated_at: '2024-02-15T03:24:32.574Z'
+ api_key_owner: elastic
+ notify_when: null
+ mute_all: false
+ muted_alert_ids: []
+ scheduled_task_id: b6883f9d-5f70-4758-a66e-369d7c26012f
+ execution_status:
+ status: ok
+ last_execution_date: '2024-02-15T03:25:38.125Z'
+ last_duration: 74
+ actions: []
+ last_run:
+ alerts_count:
+ active: 0
+ new: 0
+ recovered: 0
+ ignored: 0
+ outcome_msg: null
+ outcome_order: 0
+ outcome: succeeded
+ warning: null
+ next_run: '2024-02-15T03:26:38.033Z'
+ api_key_created_by_user: false
\ No newline at end of file
diff --git a/src/platform/packages/shared/response-ops/rule_params/index.ts b/src/platform/packages/shared/response-ops/rule_params/index.ts
index a5ce640a4c5d4..4f9f32dbe4f9e 100644
--- a/src/platform/packages/shared/response-ops/rule_params/index.ts
+++ b/src/platform/packages/shared/response-ops/rule_params/index.ts
@@ -12,6 +12,7 @@ export { ruleParamsSchema, ruleParamsSchemaWithDefaultValue } from './latest';
export {
ruleParamsSchema as ruleParamsSchemaV1,
ruleParamsSchemaWithDefaultValue as ruleParamsSchemaWithDefaultValueV1,
+ createRuleParamsExamples as createRuleParamsExamplesV1,
} from './v1';
export type { RuleParams } from './latest';
diff --git a/src/platform/packages/shared/response-ops/rule_params/index_threshold/create_index_threshold_rule_request.yaml b/src/platform/packages/shared/response-ops/rule_params/index_threshold/create_index_threshold_rule_request.yaml
new file mode 100644
index 0000000000000..146b0cff7d32b
--- /dev/null
+++ b/src/platform/packages/shared/response-ops/rule_params/index_threshold/create_index_threshold_rule_request.yaml
@@ -0,0 +1,36 @@
+summary: Index threshold rule
+description: >
+ Create an index threshold rule that uses a server log connector to send notifications when the threshold is met.
+value:
+ actions:
+ - id: 48de3460-f401-11ed-9f8e-399c75a2deeb
+ frequency:
+ notify_when: onActionGroupChange
+ summary: false
+ group: threshold met
+ params:
+ level: info
+ message: "Rule '{{rule.name}}' is active for group '{{context.group}}':\n\n- Value: {{context.value}}\n- Conditions Met: {{context.conditions}} over {{rule.params.timeWindowSize}}{{rule.params.timeWindowUnit}}\n- Timestamp: {{context.date}}"
+ alert_delay:
+ active: 3
+ consumer: alerts
+ name: my rule
+ params:
+ aggType: avg
+ termSize: 6
+ thresholdComparator: ">"
+ timeWindowSize: 5
+ timeWindowUnit: m
+ groupBy: top
+ threshold:
+ - 1000
+ index:
+ - .test-index
+ timeField: "@timestamp"
+ aggField: sheet.version
+ termField: name.keyword
+ rule_type_id: .index-threshold
+ schedule:
+ interval: 1m
+ tags:
+ - cpu
\ No newline at end of file
diff --git a/src/platform/packages/shared/response-ops/rule_params/index_threshold/create_index_threshold_rule_response.yaml b/src/platform/packages/shared/response-ops/rule_params/index_threshold/create_index_threshold_rule_response.yaml
new file mode 100644
index 0000000000000..00de25aa06763
--- /dev/null
+++ b/src/platform/packages/shared/response-ops/rule_params/index_threshold/create_index_threshold_rule_response.yaml
@@ -0,0 +1,56 @@
+summary: Index threshold rule
+description: The response for successfully creating an index threshold rule.
+value:
+ actions:
+ - group: threshold met
+ id: dceeb5d0-6b41-11eb-802b-85b0c1bc8ba2
+ uuid: 07aef2a0-9eed-4ef9-94ec-39ba58eb609d
+ connector_type_id: .server-log
+ frequency:
+ notify_when: onActionGroupChange
+ summary: false
+ throttle: null
+ params:
+ level: info
+ message: "Rule {{rule.name}} is active for group {{context.group} :\n\n- Value: {{context.value}}\n- Conditions Met: {{context.conditions}} over {{rule.params.timeWindowSize}}{{rule.params.timeWindowUnit}}\n- Timestamp: {{context.date}}"
+ alert_delay:
+ active: 3
+ api_key_created_by_user: false
+ api_key_owner: elastic
+ consumer: alerts
+ created_at: '2022-06-08T17:20:31.632Z'
+ created_by: elastic
+ enabled: true
+ execution_status:
+ last_execution_date: '2022-06-08T17:20:31.632Z'
+ status: pending
+ id: 41893910-6bca-11eb-9e0d-85d233e3ee35
+ muted_alert_ids: []
+ mute_all: false
+ name: my rule
+ notify_when: null
+ params:
+ aggType: avg
+ termSize: 6
+ thresholdComparator: ">"
+ timeWindowSize: 5
+ timeWindowUnit: m
+ groupBy: top
+ threshold:
+ - 1000
+ index:
+ - ".test-index"
+ timeField: "@timestamp"
+ aggField: sheet.version
+ termField: name.keyword
+ revision: 0
+ rule_type_id: .index-threshold
+ running: false
+ schedule:
+ interval: 1m
+ scheduled_task_id: 425b0800-6bca-11eb-9e0d-85d233e3ee35
+ tags:
+ - cpu
+ throttle: null
+ updated_at: '2022-06-08T17:20:31.632Z'
+ updated_by: elastic
\ No newline at end of file
diff --git a/src/platform/packages/shared/response-ops/rule_params/v1.ts b/src/platform/packages/shared/response-ops/rule_params/v1.ts
index fcff248122c1a..1a4f134c226f0 100644
--- a/src/platform/packages/shared/response-ops/rule_params/v1.ts
+++ b/src/platform/packages/shared/response-ops/rule_params/v1.ts
@@ -6,7 +6,7 @@
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
-
+import path from 'node:path';
import type { TypeOf } from '@kbn/config-schema';
import { schema } from '@kbn/config-schema';
@@ -23,5 +23,8 @@ export const ruleParamsSchemaWithDefaultValue = schema.recordOf(
}
);
+export const createRuleParamsExamples = () =>
+ path.join(__dirname, 'examples_create_rule_params.yaml');
+
export type RuleParams = TypeOf;
export type RuleParamsWithDefaultValue = TypeOf;
diff --git a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/create/index.ts b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/create/index.ts
index b7d96ceed715c..c03220a6252d0 100644
--- a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/create/index.ts
+++ b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/create/index.ts
@@ -27,6 +27,7 @@ export {
actionSchema as actionSchemaV1,
createParamsSchema as createParamsSchemaV1,
createBodySchema as createBodySchemaV1,
+ createRuleParamsExamplesV1,
} from './schemas/v1';
export type {
diff --git a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/create/schemas/v1.ts b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/create/schemas/v1.ts
index e70df7f9dc73f..a297ebf15748a 100644
--- a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/create/schemas/v1.ts
+++ b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/create/schemas/v1.ts
@@ -6,7 +6,10 @@
*/
import { schema } from '@kbn/config-schema';
-import { ruleParamsSchemaWithDefaultValueV1 } from '@kbn/response-ops-rule-params';
+import {
+ ruleParamsSchemaWithDefaultValueV1,
+ createRuleParamsExamplesV1,
+} from '@kbn/response-ops-rule-params';
import { validateDurationV1, validateHoursV1, validateTimezoneV1 } from '../../../validation';
import { notifyWhenSchemaV1, alertDelaySchemaV1 } from '../../../response';
import { alertsFilterQuerySchemaV1 } from '../../../../alerts_filter_query';
@@ -188,6 +191,8 @@ export const createBodySchema = schema.object({
flapping: schema.maybe(schema.nullable(flappingSchemaV1)),
});
+export { createRuleParamsExamplesV1 };
+
export const createParamsSchema = schema.object({
id: schema.maybe(
schema.string({
diff --git a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/index.ts b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/index.ts
index b8ebef499e7e0..e18ee623bedb1 100644
--- a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/index.ts
+++ b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/index.ts
@@ -11,6 +11,7 @@ export type { FindRulesRequestQuery, FindRulesResponse } from './types/latest';
export {
findRulesRequestQuerySchema as findRulesRequestQuerySchemaV1,
findRulesInternalRequestBodySchema as findRulesInternalRequestBodySchemaV1,
+ findRuleParamsExamples as findRuleParamsExamplesV1,
} from './schemas/v1';
export type {
diff --git a/oas_docs/examples/find_rules_response_conditional_action.yaml b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/schemas/examples_find_rule_response_conditional_action.yaml
similarity index 100%
rename from oas_docs/examples/find_rules_response_conditional_action.yaml
rename to x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/schemas/examples_find_rule_response_conditional_action.yaml
diff --git a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/schemas/examples_find_rules.yaml b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/schemas/examples_find_rules.yaml
new file mode 100644
index 0000000000000..da3e10b7f8157
--- /dev/null
+++ b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/schemas/examples_find_rules.yaml
@@ -0,0 +1,9 @@
+responses:
+ 200:
+ content:
+ application/json:
+ examples:
+ findRulesResponse:
+ $ref: './examples_find_rule_response_conditional_action.yaml'
+ findConditionalActionRulesResponse:
+ $ref: './examples_find_rules_response.yaml'
\ No newline at end of file
diff --git a/oas_docs/examples/find_rules_response.yaml b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/schemas/examples_find_rules_response.yaml
similarity index 100%
rename from oas_docs/examples/find_rules_response.yaml
rename to x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/schemas/examples_find_rules_response.yaml
diff --git a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/schemas/v1.ts b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/schemas/v1.ts
index 06ebfdbacc54d..914a3b28e1a76 100644
--- a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/schemas/v1.ts
+++ b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/find/schemas/v1.ts
@@ -4,9 +4,11 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
-
+import path from 'node:path';
import { schema } from '@kbn/config-schema';
+export const findRuleParamsExamples = () => path.join(__dirname, 'examples_find_rules.yaml');
+
export const findRulesRequestQuerySchema = schema.object({
per_page: schema.number({
defaultValue: 10,
diff --git a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/index.ts b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/index.ts
index 2916dd655c3b9..33365b9c4ede3 100644
--- a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/index.ts
+++ b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/index.ts
@@ -26,6 +26,7 @@ export {
actionAlertsFilterSchema as actionAlertsFilterSchemaV1,
actionSchema as actionSchemaV1,
updateBodySchema as updateBodySchemaV1,
+ updateRuleParamsExamples as updateRuleParamsExamplesV1,
updateParamsSchema as updateParamsSchemaV1,
} from './schemas/v1';
diff --git a/oas_docs/examples/update_rule_request.yaml b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/schemas/examples_update_rule.request.yaml
similarity index 100%
rename from oas_docs/examples/update_rule_request.yaml
rename to x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/schemas/examples_update_rule.request.yaml
diff --git a/oas_docs/examples/update_rule_response.yaml b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/schemas/examples_update_rule.response.yaml
similarity index 100%
rename from oas_docs/examples/update_rule_response.yaml
rename to x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/schemas/examples_update_rule.response.yaml
diff --git a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/schemas/examples_update_rule.yaml b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/schemas/examples_update_rule.yaml
new file mode 100644
index 0000000000000..cead92166a769
--- /dev/null
+++ b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/schemas/examples_update_rule.yaml
@@ -0,0 +1,13 @@
+requestBody:
+ content:
+ application/json:
+ examples:
+ updateRuleRequest:
+ $ref: './examples_update_rule.request.yaml'
+responses:
+ 200:
+ content:
+ application/json:
+ examples:
+ updateRuleResponse:
+ $ref: './examples_update_rule.response.yaml'
\ No newline at end of file
diff --git a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/schemas/v1.ts b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/schemas/v1.ts
index b838d21e5cc03..baa1dca0ec5b8 100644
--- a/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/schemas/v1.ts
+++ b/x-pack/platform/plugins/shared/alerting/common/routes/rule/apis/update/schemas/v1.ts
@@ -5,6 +5,7 @@
* 2.0.
*/
+import path from 'node:path';
import { schema } from '@kbn/config-schema';
import { ruleParamsSchemaWithDefaultValueV1 } from '@kbn/response-ops-rule-params';
import { validateDurationV1, validateHoursV1, validateTimezoneV1 } from '../../../validation';
@@ -12,6 +13,8 @@ import { notifyWhenSchemaV1, alertDelaySchemaV1 } from '../../../response';
import { alertsFilterQuerySchemaV1 } from '../../../../alerts_filter_query';
import { flappingSchemaV1 } from '../../../common';
+export const updateRuleParamsExamples = () => path.join(__dirname, 'examples_update_rule.yaml');
+
export const actionFrequencySchema = schema.object({
summary: schema.boolean({
meta: { description: 'Indicates whether the action is a summary.' },
@@ -121,6 +124,8 @@ export const actionSchema = schema.object(
}
);
+export const findRuleParamsExamples = () => path.join(__dirname, 'examples_update_rule.yaml');
+
export const updateBodySchema = schema.object({
name: schema.string({
meta: {
diff --git a/x-pack/platform/plugins/shared/alerting/server/routes/rule/apis/create/create_rule_route.ts b/x-pack/platform/plugins/shared/alerting/server/routes/rule/apis/create/create_rule_route.ts
index ed97c10d039a1..ad874754c1184 100644
--- a/x-pack/platform/plugins/shared/alerting/server/routes/rule/apis/create/create_rule_route.ts
+++ b/x-pack/platform/plugins/shared/alerting/server/routes/rule/apis/create/create_rule_route.ts
@@ -14,6 +14,7 @@ import type {
import {
createBodySchemaV1,
createParamsSchemaV1,
+ createRuleParamsExamplesV1,
} from '../../../../../common/routes/rule/apis/create';
import type { RuleParamsV1 } from '../../../../../common/routes/rule/response';
import { ruleResponseSchemaV1 } from '../../../../../common/routes/rule/response';
@@ -39,6 +40,7 @@ export const createRuleRoute = ({ router, licenseState, usageCounter }: RouteOpt
access: 'public',
summary: `Create a rule`,
tags: ['oas-tag:alerting'],
+ oasOperationObject: createRuleParamsExamplesV1,
},
validate: {
request: {
diff --git a/x-pack/platform/plugins/shared/alerting/server/routes/rule/apis/find/find_rules_route.ts b/x-pack/platform/plugins/shared/alerting/server/routes/rule/apis/find/find_rules_route.ts
index 2aa7550e7b017..29a4a2da35698 100644
--- a/x-pack/platform/plugins/shared/alerting/server/routes/rule/apis/find/find_rules_route.ts
+++ b/x-pack/platform/plugins/shared/alerting/server/routes/rule/apis/find/find_rules_route.ts
@@ -11,7 +11,10 @@ import type {
FindRulesRequestQueryV1,
FindRulesResponseV1,
} from '../../../../../common/routes/rule/apis/find';
-import { findRulesRequestQuerySchemaV1 } from '../../../../../common/routes/rule/apis/find';
+import {
+ findRulesRequestQuerySchemaV1,
+ findRuleParamsExamplesV1,
+} from '../../../../../common/routes/rule/apis/find';
import type { RuleParamsV1 } from '../../../../../common/routes/rule/response';
import { ruleResponseSchemaV1 } from '../../../../../common/routes/rule/response';
import type { ILicenseState } from '../../../../lib';
@@ -35,6 +38,7 @@ export const findRulesRoute = (
access: 'public',
summary: 'Get information about rules',
tags: ['oas-tag:alerting'],
+ oasOperationObject: findRuleParamsExamplesV1,
},
validate: {
request: {
diff --git a/x-pack/platform/plugins/shared/alerting/server/routes/rule/apis/update/update_rule_route.ts b/x-pack/platform/plugins/shared/alerting/server/routes/rule/apis/update/update_rule_route.ts
index 663f7aac47988..dab9fce7230b3 100644
--- a/x-pack/platform/plugins/shared/alerting/server/routes/rule/apis/update/update_rule_route.ts
+++ b/x-pack/platform/plugins/shared/alerting/server/routes/rule/apis/update/update_rule_route.ts
@@ -14,6 +14,7 @@ import type {
import {
updateBodySchemaV1,
updateParamsSchemaV1,
+ updateRuleParamsExamplesV1,
} from '../../../../../common/routes/rule/apis/update';
import type { RuleParamsV1 } from '../../../../../common/routes/rule/response';
import { ruleResponseSchemaV1 } from '../../../../../common/routes/rule/response';
@@ -40,6 +41,7 @@ export const updateRuleRoute = (
access: 'public',
summary: `Update a rule`,
tags: ['oas-tag:alerting'],
+ oasOperationObject: updateRuleParamsExamplesV1,
},
validate: {
request: {
diff --git a/yarn.lock b/yarn.lock
index c7d8cfc1734c3..08f3e2c7a5b4c 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -71,7 +71,7 @@
"@jridgewell/gen-mapping" "^0.1.0"
"@jridgewell/trace-mapping" "^0.3.9"
-"@apidevtools/json-schema-ref-parser@11.7.2", "@apidevtools/json-schema-ref-parser@^11.5.5":
+"@apidevtools/json-schema-ref-parser@11.7.2":
version "11.7.2"
resolved "https://registry.yarnpkg.com/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-11.7.2.tgz#cdf3e0aded21492364a70e193b45b7cf4177f031"
integrity sha512-4gY54eEGEstClvEkGnwVkTkrx0sqwemEFG5OSRRn3tD91XH0+Q8XIkYIfo7IwEWPpJZwILb9GUXeShtplRc/eA==
@@ -80,6 +80,15 @@
"@types/json-schema" "^7.0.15"
js-yaml "^4.1.0"
+"@apidevtools/json-schema-ref-parser@^11.5.5", "@apidevtools/json-schema-ref-parser@^11.9.1":
+ version "11.9.1"
+ resolved "https://registry.yarnpkg.com/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-11.9.1.tgz#51d297224f6ee1dab40dfb2dfe298812b8e0ef9c"
+ integrity sha512-OvyhwtYaWSTfo8NfibmFlgl+pIMaBOmN0OwZ3CPaGscEK3B8FCVDuQ7zgxY8seU/1kfSvNWnyB0DtKJyNLxX7g==
+ dependencies:
+ "@jsdevtools/ono" "^7.1.3"
+ "@types/json-schema" "^7.0.15"
+ js-yaml "^4.1.0"
+
"@apidevtools/json-schema-ref-parser@^9.0.6":
version "9.0.9"
resolved "https://registry.yarnpkg.com/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz#d720f9256e3609621280584f2b47ae165359268b"