asyncapi / studio

Visually design your AsyncAPI files and event-driven architecture.
https://studio.asyncapi.com
Apache License 2.0
162 stars 98 forks source link

Studio showing errors that are not really there #887

Closed derberg closed 6 months ago

derberg commented 9 months ago

Describe the bug

Studio shows errors that are not errors (however strange it sounds). I do know if it is issue related to parser only or some wrong interpretation of parser errors in studio.

How to Reproduce

Open https://studio.asyncapi.com/?url=https://raw.githubusercontent.com/asyncapi/spec/d78dcea70c9b094a3df72f9a4e811828cec778cc/examples/adeo-kafka-request-reply-asyncapi.yml and you will see some errors that you try to investigate but "they are not really there" - I mean they do not really are problems, and do not need to be solved.

There is only one valid issue with this file, lines 242-245

      bindings:
        kafka:
          key:
            $ref: "https://deploy-preview-921--asyncapi-website.netlify.app/resources/casestudies/adeo/CostingResponseKey.avsc"

If you remove above. There are all suddenly no errors anymore and docs get rendered. This issue is related to: https://github.com/asyncapi/spec-json-schemas/pull/466

Expected behavior

I should see that my yaml has error in line 245, that I'm referencing file in wrong format

Amzani commented 9 months ago

@derberg related to parser-js The diagnostic object looks like this

[
  {
    "code": "asyncapi-document-resolved",
    "message": "\"kafka\" property must match \"then\" schema",
    "path": [
      "components",
      "messages",
      "costingResponse",
      "bindings",
      "kafka"
    ],
    "severity": 0,
    "source": "asyncapi.yaml",
    "range": {
      "start": {
        "line": 268,
        "character": 18
      },
      "end": {
        "line": 270,
        "character": 131
      }
    }
  },
  {
    "code": "asyncapi-document-resolved",
    "message": "\"type\" property must be equal to one of the allowed values: \"array\", \"boolean\", \"integer\", \"null\", \"number\", \"object\", \"string\"",
    "path": [
      "type"
    ],
    "severity": 0,
    "source": "https://deploy-preview-921--asyncapi-website.netlify.app/resources/casestudies/adeo/CostingResponseKey.avsc",
    "range": {
      "start": {
        "line": 2,
        "character": 10
      },
      "end": {
        "line": 2,
        "character": 18
      }
    }
  }
]

@smoya any ideas ? is this related to spectral rules or the parser engine ?

smoya commented 9 months ago

Im away from keys at this moment, but it seems to me lines are referring to the document after resolving references.

Pending to check, obviously.

Amzani commented 7 months ago

ping @smoya

smoya commented 7 months ago

@Amzani @derberg This issue seems to be fixed now.