11import path from 'path' ;
22import { merge } from 'lodash' ;
3- import { Parser } from '@asyncapi/parser' ;
43import {
54 resolve ,
65 versionCheck ,
@@ -10,7 +9,8 @@ import {
109
1110import { Document } from './document' ;
1211
13- import type { AsyncAPIObject } from './spec-types' ;
12+ import type { AsyncAPIObject , Options } from './spec-types' ;
13+ export type { AsyncAPIObject , Options } from './spec-types' ;
1414
1515// remember the directory where execution of the program started
1616const originDir = String ( process . cwd ( ) ) ;
@@ -89,12 +89,9 @@ const originDir = String(process.cwd());
8989 */
9090export default async function bundle (
9191 files : string [ ] | string ,
92- options : any = { }
92+ options : Options = { }
9393) {
9494 let bundledDocument : any = { } ;
95- let validationResult : any = [ ] ;
96-
97- const parser = new Parser ( ) ;
9895
9996 // if one string was passed, convert it to an array
10097 if ( typeof files === 'string' ) {
@@ -128,31 +125,6 @@ export default async function bundle(
128125 // properties into a familiar form.
129126 bundledDocument = orderPropsAccToAsyncAPISpec ( bundledDocument ) ;
130127
131- // Option `noValidation: true` is used by the testing system, which
132- // intentionally feeds Bundler wrong AsyncAPI Documents, thus it is not
133- // documented.
134- if ( ! options . noValidation ) {
135- validationResult = await parser . validate (
136- JSON . parse ( JSON . stringify ( bundledDocument ) )
137- ) ;
138- }
139-
140- // If Parser's `validate()` function returns a non-empty array with at least
141- // one `severity: 0`, that means there was at least one error during
142- // validation, not a `warning: 1`, `info: 2`, or `hint: 3`. Thus, array's
143- // elements with `severity: 0` are outputted as a list of remarks, and the
144- // program throws.
145- if (
146- validationResult . length !== 0 &&
147- validationResult . map ( ( element : any ) => element . severity ) . includes ( 0 )
148- ) {
149- console . log (
150- 'Validation of the resulting AsyncAPI Document failed.\nList of remarks:\n' ,
151- validationResult . filter ( ( element : any ) => element . severity === 0 )
152- ) ;
153- throw new Error ( ) ;
154- }
155-
156128 // return to the starting directory before finishing the execution
157129 if ( options . baseDir ) {
158130 process . chdir ( originDir ) ;
0 commit comments