asyncapi / vs-asyncapi-preview

VSCode AsyncAPI Preview Extension
Apache License 2.0
41 stars 26 forks source link

JSON Schema preview is broken #194

Closed kbolino closed 9 months ago

kbolino commented 1 year ago

Describe the bug

If I try to preview a JSON schema file which has no connection to AsyncAPI, I get a white page with black text that says only:

Error: The asyncapi field is missing.

How to Reproduce

Create a file test.schema.json with the following content:

{"$schema": "https://json-schema.org/draft-07/schema"}

Then click the "Preview AsyncAPI" button or Cmd+Shift+P (macOS) and select the option.

Screenshot 2023-09-27 at 18 22 38

This appears to be identical to this issue from a similar plugin for IDEA.

Expected behavior

Either the preview option should be unavailable (because it doesn't work on this file type) or, even better, I should see a nice overview of the schema (assuming it was not trivial, like the example I gave).

github-actions[bot] commented 1 year ago

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

ivangsa commented 1 year ago

@kbolino thanks for reporting this issue. We will fix this disabling AsyncAPI preview for non asyncapi files.

Savio629 commented 9 months ago

So while debugging I found out that the isAsyncapi value could have caused the issue->

For asyncapi.yaml files

yamlisasyncapi

For asyncapi.json files

jsonisasyncapi

For non asyncapi (json) files

wrongjsonisasyncapi

So by just adding the following condition AsyncAPI preview will be disable for non asyncapi files ->

isasyncapi1

Also for best practices would prefer using parenthesis here ->

packagejsonerror

Savio629 commented 9 months ago

Should I open a pull request?

asyncapi-bot commented 9 months ago

:tada: This issue has been resolved in version 0.6.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: