From 2cddec7e5fee0bf1c23ae849ef2090e2f9de3ae7 Mon Sep 17 00:00:00 2001 From: Maxim Palenov Date: Tue, 29 Oct 2024 05:47:18 +0100 Subject: [PATCH] enable x-internal support in bundler's merge utility --- .../kbn-openapi-bundler/src/bundler/processor_sets.ts | 10 ++++++++++ packages/kbn-openapi-bundler/src/openapi_merger.ts | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/kbn-openapi-bundler/src/bundler/processor_sets.ts b/packages/kbn-openapi-bundler/src/bundler/processor_sets.ts index 1252d48654bf6..a385c196f8d3b 100644 --- a/packages/kbn-openapi-bundler/src/bundler/processor_sets.ts +++ b/packages/kbn-openapi-bundler/src/bundler/processor_sets.ts @@ -39,6 +39,16 @@ export const DEFAULT_BUNDLING_PROCESSORS: Readonly = [ createUnfoldSingleAllOfItemProcessor(), ]; +/** + * Processors which should be applied to documents before merging them together. + */ +export const DEFAULT_MERGING_PROCESSORS: Readonly = [ + // x-internal is quite well known custom property to skip internal API parts. + // Enabling it to avoid leaking internal APIs/API parts coming from non processed + // by the bundler Kibana domains. + createSkipNodeWithInternalPropProcessor(X_INTERNAL), +]; + /** * Adds createIncludeLabelsProcessor processor, see createIncludeLabelsProcessor description * for more details diff --git a/packages/kbn-openapi-bundler/src/openapi_merger.ts b/packages/kbn-openapi-bundler/src/openapi_merger.ts index c1e76cfc7f9a1..5589c0689036e 100644 --- a/packages/kbn-openapi-bundler/src/openapi_merger.ts +++ b/packages/kbn-openapi-bundler/src/openapi_merger.ts @@ -16,7 +16,10 @@ import { ResolvedDocument } from './bundler/ref_resolver/resolved_document'; import { writeDocuments } from './utils/write_documents'; import { resolveGlobs } from './utils/resolve_globs'; import { bundleDocument } from './bundler/bundle_document'; -import { withNamespaceComponentsProcessor } from './bundler/processor_sets'; +import { + DEFAULT_MERGING_PROCESSORS, + withNamespaceComponentsProcessor, +} from './bundler/processor_sets'; import { PrototypeDocument } from './prototype_document'; import { validatePrototypeDocument } from './validate_prototype_document'; @@ -94,7 +97,10 @@ function logSchemas(schemaFilePaths: string[]): void { async function bundleDocuments(schemaFilePaths: string[]): Promise { return await Promise.all( schemaFilePaths.map(async (schemaFilePath) => - bundleDocument(schemaFilePath, withNamespaceComponentsProcessor([], '/info/title')) + bundleDocument( + schemaFilePath, + withNamespaceComponentsProcessor(DEFAULT_MERGING_PROCESSORS, '/info/title') + ) ) ); }