diff --git a/packages/parser/src/parse.ts b/packages/parser/src/parse.ts index 9688a4314..d61dfc8f2 100644 --- a/packages/parser/src/parse.ts +++ b/packages/parser/src/parse.ts @@ -44,18 +44,8 @@ export async function parse(parser: Parser, spectral: Spectral, asyncapi: Input, try { options = mergePatch(defaultOptions, options); - // Normalize input to always be JSON - let loadedObj; - if (typeof asyncapi === 'string') { - try { - loadedObj = yaml.load(asyncapi); - } catch (e) { - loadedObj = JSON.parse(asyncapi); - } - } else { - loadedObj = asyncapi; - } - const { validated, diagnostics, extras } = await validate(parser, spectral, loadedObj, { ...options.validateOptions, source: options.source, __unstable: options.__unstable }); + + const { validated, diagnostics, extras } = await validate(parser, spectral, asyncapi, { ...options.validateOptions, source: options.source, __unstable: options.__unstable }); if (validated === undefined) { return { document: undefined, @@ -72,7 +62,7 @@ export async function parse(parser: Parser, spectral: Spectral, asyncapi: Input, // Apply unique ids which are used as part of iterating between channels <-> operations <-> messages applyUniqueIds(validatedDoc); - const detailed = createDetailedAsyncAPI(validatedDoc, loadedObj as DetailedAsyncAPI['input'], options.source); + const detailed = createDetailedAsyncAPI(validatedDoc, asyncapi as DetailedAsyncAPI['input'], options.source); const document = createAsyncAPIDocument(detailed); setExtension(xParserSpecParsed, true, document); setExtension(xParserApiVersion, ParserAPIVersion, document);