Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HTTP/OAS] Enable x-internal prop support in bundler's merge utility #198104

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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