asyncapi / parser-js

AsyncAPI parser for Javascript (browser-compatible too).
Apache License 2.0
119 stars 97 forks source link

fix: remove forceful normalization of YAML to JSON #1044

Closed aeworxet closed 2 months ago

aeworxet commented 3 months ago

This PR removes forceful normalization of YAML files to JSON format to fix https://github.com/asyncapi/parser-js/issues/936, which in its turn lays the foundation for reporting correct range values in error diagnostics for YAML files in Studio.

Related to https://github.com/asyncapi/parser-js/issues/1012

changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: dc621f9dd24306f763a1d09a24936ac6772c65c0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ---------------- | ----- | | @asyncapi/parser | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

aeworxet commented 3 months ago

@asyncapi/bounty_team

smoya commented 3 months ago

@aeworxet it would be worth adding a comment in https://github.com/asyncapi/parser-js/blob/master/packages/parser/src/validate.ts#L49 mentioning Spectral uses the https://github.com/stoplightio/yaml parser, and basically, JSON is a valid YAML doc, so no matters if you pass YAML or JSON, that YAML parser will be able to parse it.

Additionally, please add two new unit tests in for the validate method testing at least one string input for JSON and another for YAML.

aeworxet commented 3 months ago

Updated PR.

aeworxet commented 3 months ago

Credits for the pack of changes in packages/parser/test/parse.spec.ts go to eslint --fix; otherwise, Sonar complained.

sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

aeworxet commented 2 months ago

/rtm