[Security Solution] Auto-bundle Lists API OpenAPI specs (#188407)

**Addresses**: https://github.com/elastic/kibana/issues/184428

## Summary

This PR adds scripts for automatic bundling of Lists API OpenAPI specs as a part of PR pipeline. Corresponding resulting bundles are automatically committed in the Lists common package `kbn-securitysolution-lists-common` in the `docs/openapi/ess/` and `docs/openapi/serverless` folders (similar to https://github.com/elastic/kibana/pull/186384).
This commit is contained in:
Maxim Palenov 2024-07-18 13:33:53 +02:00 committed by GitHub
parent 9d4c061247
commit c76f68e55c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 3102 additions and 5 deletions

View file

@ -8,3 +8,6 @@ echo --- Security Solution OpenAPI Bundling
(cd x-pack/plugins/security_solution && yarn openapi:bundle)
check_for_changed_files "yarn openapi:bundle" true
(cd packages/kbn-securitysolution-lists-common && yarn openapi:bundle)
check_for_changed_files "yarn openapi:bundle" true

View file

@ -5,6 +5,7 @@ info:
paths:
/api/lists/items/_export:
post:
x-labels: [serverless, ess]
operationId: ExportListItems
x-codegen-enabled: true
summary: Exports list items

View file

@ -3,7 +3,7 @@ info:
title: Find list items API endpoint
version: '2023-10-31'
paths:
/api/lists/_find:
/api/lists/items/_find:
get:
x-labels: [serverless, ess]
operationId: FindListItems

View file

@ -5,6 +5,7 @@ info:
paths:
/api/lists/items/_import:
post:
x-labels: [serverless, ess]
operationId: ImportListItems
x-codegen-enabled: true
summary: Imports list items

View file

@ -5,6 +5,7 @@
"private": true,
"version": "1.0.0",
"scripts": {
"openapi:generate": "node scripts/openapi_generate"
"openapi:generate": "node scripts/openapi_generate",
"openapi:bundle": "node scripts/openapi_bundle"
}
}

View file

@ -0,0 +1,45 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/
require('../../../src/setup_node_env');
const { join, resolve } = require('path');
const { bundle } = require('@kbn/openapi-bundler');
const ROOT = resolve(__dirname, '..');
(async () => {
await bundle({
sourceGlob: join(ROOT, 'api/**/*.schema.yaml'),
outputFilePath: join(
ROOT,
'docs/openapi/serverless/security_solution_lists_api_{version}.bundled.schema.yaml'
),
options: {
includeLabels: ['serverless'],
specInfo: {
title: 'Security Solution Lists API (Elastic Cloud Serverless)',
description: 'Lists API allows you to manage lists of keywords, IPs or IP ranges items.',
},
},
});
await bundle({
sourceGlob: join(ROOT, 'api/**/*.schema.yaml'),
outputFilePath: join(
ROOT,
'docs/openapi/ess/security_solution_lists_api_{version}.bundled.schema.yaml'
),
options: {
includeLabels: ['ess'],
specInfo: {
title: 'Security Solution Lists API (Elastic Cloud and self-hosted)',
description: 'Lists API allows you to manage lists of keywords, IPs or IP ranges items.',
},
},
});
})();

View file

@ -17,14 +17,14 @@ const ROOT = resolve(__dirname, '..');
await generate({
title: 'OpenAPI Lists API Schemas',
rootDir: ROOT,
sourceGlob: './**/*.schema.yaml',
sourceGlob: './api/**/*.schema.yaml',
templateName: 'zod_operation_schema',
});
await generate({
title: 'Lists API client for tests',
rootDir: ROOT,
sourceGlob: './**/*.schema.yaml',
sourceGlob: './api/**/*.schema.yaml',
templateName: 'api_client_supertest',
skipLinting: true,
bundle: {

View file

@ -98,7 +98,7 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext)
},
findListItems(props: FindListItemsProps) {
return supertest
.get('/api/lists/_find')
.get('/api/lists/items/_find')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')