Skip to content

Commit

Permalink
enable x-internal support in bundler's merge utility
Browse files Browse the repository at this point in the history
  • Loading branch information
maximpn committed Oct 29, 2024
1 parent 686b021 commit 2cddec7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 10 additions & 0 deletions packages/kbn-openapi-bundler/src/bundler/processor_sets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ export const DEFAULT_BUNDLING_PROCESSORS: Readonly<DocumentNodeProcessor[]> = [
createUnfoldSingleAllOfItemProcessor(),
];

/**
* Processors which should be applied to documents before merging them together.
*/
export const DEFAULT_MERGING_PROCESSORS: Readonly<DocumentNodeProcessor[]> = [
// 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
Expand Down
10 changes: 8 additions & 2 deletions packages/kbn-openapi-bundler/src/openapi_merger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -94,7 +97,10 @@ function logSchemas(schemaFilePaths: string[]): void {
async function bundleDocuments(schemaFilePaths: string[]): Promise<ResolvedDocument[]> {
return await Promise.all(
schemaFilePaths.map(async (schemaFilePath) =>
bundleDocument(schemaFilePath, withNamespaceComponentsProcessor([], '/info/title'))
bundleDocument(
schemaFilePath,
withNamespaceComponentsProcessor(DEFAULT_MERGING_PROCESSORS, '/info/title')
)
)
);
}
Expand Down

0 comments on commit 2cddec7

Please sign in to comment.