asyncapi / asyncapi-react

React component for rendering documentation from your specification in real-time in the browser. It also provides a WebComponent and bundle for Angular and Vue
https://asyncapi.github.io/asyncapi-react/
Apache License 2.0
188 stars 126 forks source link

fix: informative Stubs when document is invalid #1068

Closed catosaurusrex2003 closed 1 month ago

catosaurusrex2003 commented 1 month ago

Description Diagnostics with severity 0 are displayed as errors.

Before (Invalid document 👇 with syntax error) image

After (Invalid document 👇 with syntax error) image

(document with spec specific errors 👇) image

Related Issue

1048

874

catosaurusrex2003 commented 1 month ago

The line in diagnostics being returned by the parser is not accurate when there are multi-line strings or when the lines move back indentations.

@derberg should we include the line number in the errors ?

example: below error should be on line 12, but it is showing on line 7 cuz it ignored the multi-lined string of /info/description image

catosaurusrex2003 commented 1 month ago

I upgraded the package @asyncapi/parser from 3.1.0 -> 3.3.0 and now the error lines are reliable and working correctly

sonarcloud[bot] commented 1 month 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

AceTheCreator commented 1 month ago

/rtm

AceTheCreator commented 1 month ago

@catosaurusrex2003, i noticed something after merging this PR that the error line seem not to be acccurate for some of the errors just as seen below. It should be line 3 not line 4 🤔 AsyncAPI-React-Playground-App-10-07-2024_06_34_PM

AceTheCreator commented 1 month ago

Wanna fix this in a follow-up PR?

asyncapi-bot commented 1 month ago

:tada: This PR is included in version 2.2.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

catosaurusrex2003 commented 1 month ago

@AceTheCreator I would love to work on this. But I cant seem to reproduce this issue again.

i tried the below on https://asyncapi.github.io/asyncapi-react/ image and it is giving correct line number error

could it be you are running it locally without reinstalling the nodemodules again, cuz our @asyncapi/parser dependency version changed in the pr.

AceTheCreator commented 1 month ago

Yea, that was the reason 😄. Everything looks good 🚀

Thanks for the fix 👍🏾