Skip to content

Commit

Permalink
add comment and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aeworxet committed Jul 3, 2024
1 parent 087a11f commit ef47774
Show file tree
Hide file tree
Showing 2 changed files with 951 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/parser/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ export async function parse(parser: Parser, spectral: Spectral, asyncapi: Input,

try {
options = mergePatch<ParseOptions>(defaultOptions, options);


// `./src/validate.ts` enforces 'string' type on both YAML and JSON later in
// code, and parses them both using the same `@stoplight/yaml`, so forceful
// normalization of YAML to JSON here has no practical application. It only
// causes `range` to be reported incorrectly in `diagnostics` by misleading
// `Parser` into thinking it's dealing with JSON instead of YAML, creating
// the bug described in https://github.com/asyncapi/parser-js/issues/936

const { validated, diagnostics, extras } = await validate(parser, spectral, asyncapi, { ...options.validateOptions, source: options.source, __unstable: options.__unstable });
if (validated === undefined) {
return {
Expand Down
Loading

0 comments on commit ef47774

Please sign in to comment.