Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Intellij shows error "Missing required property $ref" in AsyncAPI 3.0.0 document #49

Closed
2 tasks done
timonback opened this issue Mar 8, 2024 · 23 comments · Fixed by asyncapi/spec-json-schemas#495
Assignees
Labels
bug Something isn't working

Comments

@timonback
Copy link

Describe the bug.

The provided specs are valid AsyncAPI to the best of our knowledge. The asyncapi/parser + AsyncAPI Studio shows these files as valid.

However, the Intellij plugin shows errors

Expected behavior

No errors in the AsyncAPI plugin.

Similar or identical validation to studio.asyncapi.com

Screenshots

How to Reproduce

Open one of the example files in Springwolf, for example:

🥦 Browser

None

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

No, someone else can work on it

@timonback timonback added the bug Something isn't working label Mar 8, 2024
Copy link

github-actions bot commented Mar 8, 2024

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.

@Pakisan Pakisan self-assigned this Mar 8, 2024
@Pakisan
Copy link
Member

Pakisan commented Mar 8, 2024

Describe the bug.

The provided specs are valid AsyncAPI to the best of our knowledge. The asyncapi/parser + AsyncAPI Studio shows these files as valid.

However, the Intellij plugin shows errors

Expected behavior

No errors in the AsyncAPI plugin.

Similar or identical validation to studio.asyncapi.com

Screenshots

How to Reproduce

Open one of the example files in Springwolf, for example:

🥦 Browser

None

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

No, someone else can work on it

Will check it today. It may be bug in editor or validator

@theschles
Copy link
Member

@Pakisan confirmed that the asyncapi files to which @timonback provided links both pass validation:

springwolf-core/springwolf-examples/springwolf-sqs-example/src/test/resources on  master via ⬡ v8.6 via ☕️ v17.0.5
➜ asyncapi --version
@asyncapi/cli/1.6.1 darwin-arm64 node-v20.10.0

springwolf-core/springwolf-examples/springwolf-sqs-example/src/test/resources on  master via ⬡ v8.6 via ☕️ v17.0.5
➜ asyncapi validate asyncapi.json

File asyncapi.json is valid! File asyncapi.json and referenced documents don't have governance issues.

springwolf-core/springwolf-examples/springwolf-sqs-example/src/test/resources on  master via ⬡ v8.6 via ☕️ v17.0.5
➜ cd ../../../../springwolf-amqp-example/src/test/resources

springwolf-core/springwolf-examples/springwolf-amqp-example/src/test/resources on  master via ⬡ v8.6 via ☕️ v17.0.5
➜ asyncapi validate asyncapi.json

File asyncapi.json is valid! File asyncapi.json and referenced documents don't have governance issues.

@theschles
Copy link
Member

theschles commented Mar 9, 2024

Here are some of the problems seemingly reported by plugin 2.4.0+jre17 on

IntelliJ IDEA 2023.3.2 (Community Edition)
Build #IC-233.13135.103, built on December 19, 2023
Runtime version: 17.0.9+7-b1087.9 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 14.3.1
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 10
Metal Rendering is ON
Registry:
  ide.experimental.ui=true
Non-Bundled Plugins:
  com.asyncapi.plugin.idea (2.4.0+jre17)
Kotlin: 233.13135.103-IJ
image

...and...

image

@Pakisan
Copy link
Member

Pakisan commented Mar 9, 2024

@theschles thanks)

I have built new version, at night, with updated schema. Will check on todays morning

@Pakisan
Copy link
Member

Pakisan commented Mar 10, 2024

@theschles @timonback not easy one problem. Awesome mix of bugs in IDEA related to anyOf, oneOf and issues in our Json Schemas.

Need more time to dig into @asyncapi/cli and figure out which schemas they are using for validation

upd:

@Souvikns @magicmatatjahu can you help me?

@Pakisan
Copy link
Member

Pakisan commented Mar 10, 2024

ok. looks like problem is in payload validation:

it's ok

"io.github.springwolf.examples.amqp.dtos.AnotherPayloadDto": {
        "headers": {
          "$ref": "#/components/schemas/HeadersNotDocumented"
        },
        "payload": {
          "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0"
        },
        "name": "io.github.springwolf.examples.amqp.dtos.AnotherPayloadDto",
        "title": "AnotherPayloadDto",
        "description": "Another payload model",
        "bindings": {
          "amqp": {
            "bindingVersion": "0.3.0"
          }
        }
      },

it's not ok

"io.github.springwolf.examples.amqp.dtos.ExamplePayloadDto": {
        "headers": {
          "$ref": "#/components/schemas/HeadersNotDocumented"
        },
        "payload": {
          "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0",
          "schema": {
            "$ref": "#/components/schemas/io.github.springwolf.examples.amqp.dtos.ExamplePayloadDto"
          }
        },
        "name": "io.github.springwolf.examples.amqp.dtos.ExamplePayloadDto",
        "title": "ExamplePayloadDto",
        "bindings": {
          "amqp": {
            "bindingVersion": "0.3.0"
          }
        }
      }

upd:

looks like problem related with reference, cause this is ok:

"io.github.springwolf.examples.amqp.dtos.ExamplePayloadDto": {
        "headers": {
          "$ref": "#/components/schemas/HeadersNotDocumented"
        },
        "payload": {
          "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0",
          "schema": {
            "type": "object",
            "additionalProperties": false
          }
        },
        "name": "io.github.springwolf.examples.amqp.dtos.ExamplePayloadDto",
        "title": "ExamplePayloadDto",
        "bindings": {
          "amqp": {
            "bindingVersion": "0.3.0"
          }
        }
      }

upd:

I need to ensure that problem appears only with ours schema formats, because it's ok:

"io.github.springwolf.examples.amqp.dtos.AnotherPayloadDto": {
        "headers": {
          "$ref": "#/components/schemas/HeadersNotDocumented"
        },
        "payload": {
          "schemaFormat": "application/vnd.apache.avro;version=1.9.0",
          "schema": {
            "$ref": "#/components/schemas/io.github.springwolf.examples.amqp.dtos.AnotherPayloadDto"
          }
        },
        "name": "io.github.springwolf.examples.amqp.dtos.AnotherPayloadDto",
        "title": "AnotherPayloadDto",
        "description": "Another payload model",
        "bindings": {
          "amqp": {
            "bindingVersion": "0.3.0"
          }
        }
      }

upd:

all schemaFormat that broke validation:

  • application/schema+json;version=draft-07
  • application/schema+yaml;version=draft-07
  • application/vnd.aai.asyncapi;version=2.0.0
  • application/vnd.aai.asyncapi+json;version=2.0.0
  • application/vnd.aai.asyncapi+yaml;version=2.0.0
  • application/vnd.aai.asyncapi;version=2.1.0
  • application/vnd.aai.asyncapi+json;version=2.1.0
  • application/vnd.aai.asyncapi+yaml;version=2.1.0
  • application/vnd.aai.asyncapi;version=2.2.0
  • application/vnd.aai.asyncapi+json;version=2.2.0
  • application/vnd.aai.asyncapi+yaml;version=2.2.0
  • application/vnd.aai.asyncapi;version=2.3.0
  • application/vnd.aai.asyncapi+json;version=2.3.0
  • application/vnd.aai.asyncapi+yaml;version=2.3.0
  • application/vnd.aai.asyncapi;version=2.4.0
  • application/vnd.aai.asyncapi+json;version=2.4.0
  • application/vnd.aai.asyncapi+yaml;version=2.4.0
  • application/vnd.aai.asyncapi;version=2.5.0
  • application/vnd.aai.asyncapi+json;version=2.5.0
  • application/vnd.aai.asyncapi+yaml;version=2.5.0
  • application/vnd.aai.asyncapi;version=2.6.0
  • application/vnd.aai.asyncapi+json;version=2.6.0
  • application/vnd.aai.asyncapi+yaml;version=2.6.0
  • application/vnd.aai.asyncapi;version=3.0.0
  • application/vnd.aai.asyncapi+json;version=3.0.0
  • application/vnd.aai.asyncapi+yaml;version=3.0.0

bug is here: https://github.com/asyncapi/spec-json-schemas/blob/master/schemas/3.0.0-without-%24id.json#L2671-L2873

@Pakisan
Copy link
Member

Pakisan commented Mar 10, 2024

ampq example was fixed

sqs on a way

Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Mar 10, 2024
…erencing a a json schema

Fix missing queue definition for SQS channel binding

asyncapi#494
asyncapi/jasyncapi-idea-plugin#49
Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Mar 11, 2024
…erencing a a json schema

- Revert changes from auto generated schema
- Change allOf to anyOf in multiFormatSchema

asyncapi#494
asyncapi/jasyncapi-idea-plugin#49
Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Mar 12, 2024
…erencing a json schema

Include internal definitions from bindings to composed schema

asyncapi#494
asyncapi/jasyncapi-idea-plugin#49
Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Mar 12, 2024
Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Mar 12, 2024
@Pakisan
Copy link
Member

Pakisan commented Mar 12, 2024

@timonback @theschles both examples were fixed.

I'll push updated schemas to release branch. It'll help you to re-check fix after installation of local built plugin

Pakisan added a commit that referenced this issue Mar 14, 2024
v2:
- 2.0.0
- 2.1.0
- 2.2.0
- 2.3.0
- 2.4.0
- 2.5.0
- 2.6.0
v3:
- 3.0.0

asyncapi/spec-json-schemas#494
#49
@Pakisan
Copy link
Member

Pakisan commented Mar 15, 2024

@timonback
Copy link
Author

Thanks @Pakisan , the $ref errors are mostly gone - or at least not errors anymore

I do see the following warnings, not sure if they are expected with the plugin. I am using again https://github.com/springwolf/springwolf-core/blob/master/springwolf-examples/springwolf-sqs-example/src/test/resources/asyncapi.json as it is the smallest file:

image
and
image

My Intellij didn't know about AsyncApi3 json-schema yet, so I had to manually define a file JSON Schema Mapping using this schema: https://www.asyncapi.com/definitions/3.0.0.json
Otherwise, the 2.X.0 version was used.

@Pakisan
Copy link
Member

Pakisan commented Mar 15, 2024

Thanks @Pakisan , the $ref errors are mostly gone - or at least not errors anymore

I do see the following warnings, not sure if they are expected with the plugin. I am using again https://github.com/springwolf/springwolf-core/blob/master/springwolf-examples/springwolf-sqs-example/src/test/resources/asyncapi.json as it is the smallest file:

image and image

My Intellij didn't know about AsyncApi3 json-schema yet, so I had to manually define a file JSON Schema Mapping using this schema: https://www.asyncapi.com/definitions/3.0.0.json Otherwise, the 2.X.0 version was used.

No, no, no, you don't need to define external json schema. It's already bundled in plugin

Download archive and install update manually: plugins -> gear wheel icon -> install from disk

Screenshot 2024-03-15 at 17 40 14

@timonback
Copy link
Author

Just checked it on a second machine as well (version 2.5.0+jre17):

  • No extra mapping schema necessary
  • Still it (amqp in this case) shows problems

For the schema (status bar), it states: JSON: all.schema-store.json

image

@Pakisan
Copy link
Member

Pakisan commented Mar 15, 2024

@theschles please, delete mapping with any schemas, because you are using not fixed schema from https://www.asyncapi.com/schema-store/all.schema-store.json

Screenshot 2024-03-15 at 21 13 15 Screenshot 2024-03-15 at 21 13 47 Screenshot 2024-03-15 at 21 14 00

@timonback
Copy link
Author

Thanks @Pakisan , that does the trick.

I don't think - although I might be wrong - that I have touched the default Intellij setting.
I guess it is a requirement for the AsyncApi idea plugin to disable to the "Remote JSON Schemas" > "Allow download JSON Schemas from remote sources"?

Anyway, the issue is resolved from my point of view.
Many thanks again 👍

@Pakisan
Copy link
Member

Pakisan commented Mar 15, 2024

Thanks @Pakisan , that does the trick.

I don't think - although I might be wrong - that I have touched the default Intellij setting. I guess it is a requirement for the AsyncApi idea plugin to disable to the "Remote JSON Schemas" > "Allow download JSON Schemas from remote sources"?

Anyway, the issue is resolved from my point of view. Many thanks again 👍

Great to hear, that fix is working like expected. Time to release it)

I don't think - although I might be wrong - that I have touched the default Intellij setting.
I guess it is a requirement for the AsyncApi idea plugin to disable to the "Remote JSON Schemas" > "Allow download JSON Schemas from remote sources"?

This trick will not be required after merging of this MR - asyncapi/spec-json-schemas#495. Until that my fix is not available from our side (https://www.asyncapi.com/schema-store/all.schema-store.json)

@theschles
Copy link
Member

theschles commented Mar 17, 2024

> @theschles please, delete mapping with any schemas, because you are using not fixed schema from https://www.asyncapi.com/schema-store/all.schema-store.json > Screenshot 2024-03-15 at 21 13 15 Screenshot 2024-03-15 at 21 13 47 Screenshot 2024-03-15 at 21 14 00

Hi @Pakisan @timonback -- sorry, have been heads down at work all week due to schedule pressure. Now seeing the updates to this convo.

I didn't have any specified JSON Schema Mappings at all:

image

@theschles
Copy link
Member

theschles commented Mar 17, 2024

Thanks @Pakisan , that does the trick.
I don't think - although I might be wrong - that I have touched the default Intellij setting. I guess it is a requirement for the AsyncApi idea plugin to disable to the "Remote JSON Schemas" > "Allow download JSON Schemas from remote sources"?
Anyway, the issue is resolved from my point of view. Many thanks again 👍

Great to hear, that fix is working like expected. Time to release it)

I don't think - although I might be wrong - that I have touched the default Intellij setting.
I guess it is a requirement for the AsyncApi idea plugin to disable to the "Remote JSON Schemas" > "Allow download JSON Schemas from remote sources"?

This trick will not be required after merging of this MR - asyncapi/spec-json-schemas#495. Until that my fix is not available from our side (https://www.asyncapi.com/schema-store/all.schema-store.json)

Hopefully we'll get the remaining approval(s) tomorrow:

Please @Pakisan hold on so I can review this PR on Monday. I really need to understand the implication of this change (probably will be OK, but need to understand as I worked on that particular part of the JSON Schema recently).

Hi @Pakisan - after the spec-json-schemas group approves your PR -- and when you're ready for me to review your plugin code changes -- please ping me through our usual chat system as I might not see the Github notification.

@theschles
Copy link
Member

Just to keep @Pakisan and @timonback in the loop - the reviewer asked for some changes

Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Mar 19, 2024
Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Mar 19, 2024
Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Mar 22, 2024
Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Mar 25, 2024
Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Mar 25, 2024
Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Mar 28, 2024
Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Mar 28, 2024
Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Mar 29, 2024
Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Apr 2, 2024
Pakisan added a commit to Pakisan/spec-json-schemas that referenced this issue Apr 2, 2024
@theschles
Copy link
Member

@Pakisan @timonback was this correctly resolved by the change in asyncapi/spec-json-schemas#495? ?

@timonback
Copy link
Author

Thank you @Pakisan and @theschles , the issues are resolved!

Looking forward to the official release.
As mentioned before, it might be good to explicitly documented that users should disable the intellij schema store.

@Pakisan
Copy link
Member

Pakisan commented Apr 5, 2024

Thank you @Pakisan and @theschles , the issues are resolved!

Looking forward to the official release.

As mentioned before, it might be good to explicitly documented that users should disable the intellij schema store.

You can enable now IntelliJ schema store. I think that updated schema was published after merge

I hope that release with this fix and 2024.1 will be approved by JetBrains on Monday

@Pakisan
Copy link
Member

Pakisan commented Apr 12, 2024

@timonback new version now available for downloading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants