diff --git a/README.md b/README.md index 21a6c25..a2d9574 100644 --- a/README.md +++ b/README.md @@ -202,16 +202,16 @@ There are no internal references that MUST be `Reference Object`s. Regexes of internal references that MUST be `Reference Object`s: ``` -/#\/channels\/[a-zA-Z0-9]*\/servers/ -/#\/operations\/[a-zA-Z0-9]*\/channel/ -/#\/operations\/[a-zA-Z0-9]*\/messages/ -/#\/operations\/[a-zA-Z0-9]*\/reply\/channel/ -/#\/operations\/[a-zA-Z0-9]*\/reply\/messages/ -/#\/components\/channels\/[a-zA-Z0-9]*\/servers/ -/#\/components\/operations\/[a-zA-Z0-9]*\/channel/ -/#\/components\/operations\/[a-zA-Z0-9]*\/messages/ -/#\/components\/operations\/[a-zA-Z0-9]*\/reply\/channel/ -/#\/components\/operations\/[a-zA-Z0-9]*\/reply\/messages/ +/#\/channels\/,*\/servers/ +/#\/operations\/.*\/channel/ +/#\/operations\/.*\/messages/ +/#\/operations\/.*\/reply\/channel/ +/#\/operations\/,*\/reply\/messages/ +/#\/components\/channels\/.*\/servers/ +/#\/components\/operations\/.*\/channel/ +/#\/components\/operations\/.*\/messages/ +/#\/components\/operations\/.*\/reply\/channel/ +/#\/components\/operations\/.*\/reply\/messages/ ``` @@ -230,7 +230,7 @@ However, if a user doesn't need / doesn't want `x-origin` properties to be prese ### Movement of components to `components` -The movement of all AsyncAPI Specification-valid components to the `components` section of the AsyncAPI Document is done by the [`Optimizer`](https://github.com/asyncapi/optimizer) v1.0.0+. +The movement of all AsyncAPI Specification-valid components to the `components` section of the AsyncAPI Document starting from `Bundler` v0.5.0 is done by the [`Optimizer`](https://github.com/asyncapi/optimizer) v1.0.0+. To get in CI/code an AsyncAPI Document, that is dereferenced [to its maximum possible extent](#dereference-of-the-external-references) with all of its components moved to the `components` section, the original AsyncAPI Document must be run through chain `Bundler -> Optimizer`. diff --git a/example/bundle-cjs.cjs b/example/bundle-cjs.cjs index f3f35c2..44d37ae 100644 --- a/example/bundle-cjs.cjs +++ b/example/bundle-cjs.cjs @@ -9,8 +9,8 @@ const { readFileSync, writeFileSync } = require('fs'); const bundle = require('@asyncapi/bundler'); async function main() { - const document = await bundle(['./main151.yaml', './main153.yaml'].map( f => readFileSync(f, 'utf-8')), { - xOrigin: false, + const document = await bundle([readFileSync('./main.yaml', 'utf-8')], { + xOrigin: true, }); if (document.yml()) { writeFileSync('asyncapi.yaml', document.yml()); diff --git a/example/bundle-cjs.js b/example/bundle-cjs.js index 720c3f7..5649e46 100644 --- a/example/bundle-cjs.js +++ b/example/bundle-cjs.js @@ -14,7 +14,7 @@ async function main() { const filePaths = ['./camera.yml','./audio.yml']; const document = await bundle( filePaths.map(filePath => readFileSync(filePath, 'utf-8')), { - // base: readFileSync('./base.yml', 'utf-8'), + base: readFileSync('./base.yml', 'utf-8'), xOrigin: true } ); diff --git a/src/parser.ts b/src/parser.ts index 872a2c1..427c16c 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -28,7 +28,8 @@ export async function parse( case 2: RefParserOptions = { dereference: { - circular: false, // prettier-ignore + circular: false, + // prettier-ignore excludedPathMatcher: (path: string): any => { // eslint-disable-line return; }, @@ -47,16 +48,16 @@ export async function parse( excludedPathMatcher: (path: string): any => { return ( // prettier-ignore - (/#\/channels\/[a-zA-Z0-9]*\/servers/).test(path) || - (/#\/operations\/[a-zA-Z0-9]*\/channel/).test(path) || - (/#\/operations\/[a-zA-Z0-9]*\/messages/).test(path) || - (/#\/operations\/[a-zA-Z0-9]*\/reply\/channel/).test(path) || - (/#\/operations\/[a-zA-Z0-9]*\/reply\/messages/).test(path) || - (/#\/components\/channels\/[a-zA-Z0-9]*\/servers/).test(path) || - (/#\/components\/operations\/[a-zA-Z0-9]*\/channel/).test(path) || - (/#\/components\/operations\/[a-zA-Z0-9]*\/messages/).test(path) || - (/#\/components\/operations\/[a-zA-Z0-9]*\/reply\/channel/).test(path) || - (/#\/components\/operations\/[a-zA-Z0-9]*\/reply\/messages/).test(path) + (/#\/channels\/,*\/servers/).test(path) || + (/#\/operations\/.*\/channel/).test(path) || + (/#\/operations\/.*\/messages/).test(path) || + (/#\/operations\/.*\/reply\/channel/).test(path) || + (/#\/operations\/,*\/reply\/messages/).test(path) || + (/#\/components\/channels\/.*\/servers/).test(path) || + (/#\/components\/operations\/.*\/channel/).test(path) || + (/#\/components\/operations\/.*\/messages/).test(path) || + (/#\/components\/operations\/.*\/reply\/channel/).test(path) || + (/#\/components\/operations\/.*\/reply\/messages/).test(path) ); }, onDereference: (path: string, value: AsyncAPIObject) => { diff --git a/tests/lib/index.spec.ts b/tests/lib/index.spec.ts index 7c44dc0..3566c17 100644 --- a/tests/lib/index.spec.ts +++ b/tests/lib/index.spec.ts @@ -19,7 +19,6 @@ describe('[integration testing] bundler should ', () => { noValidation: true, } ); - console.log(response.yml()) expect(response).toBeDefined(); });