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

better error handling when $ref references an external file in asyncapi #1543

Open
marianobntz opened this issue May 2, 2024 · 7 comments
Open

Comments

@marianobntz
Copy link

Is your feature request related to a problem? Please describe.

I am building my pipelines to publish APIs and when I tried to bundle the asyncapi files I found the error below

Describe the solution you'd like

Support for bundling asyncapi files is the expected solution.

Describe alternatives you've considered

not much since bunding is the whole idea...

Additional context

The error shown now is:

Something went wrong when processing .\cache-messages-1.0.json:

  • Cannot read properties of undefined (reading 'schemas')
@marianobntz marianobntz changed the title Support bundle command for asyncapi files better error handling when $ref is used instead of $schema in asyncapi May 2, 2024
@marianobntz
Copy link
Author

marianobntz commented May 2, 2024

Update
This comment is wrong, $schema and $ref are different things...
Anyway... when I use a $ref keyword referencing an external file I get the error... I tried different combinations:

  • "$ref": "components/schemas/type.json"
  • "$ref": "components/schemas/type.json#"

type.json is:

{
"type": "string",
"description": "dummy",
"pattern": "^[a-z0-9\-]+$",
"example": "supplier"
}

  • tried changing the type.json to (this is a sample, maybe I got a syntax error in this sample):

{ "components": { "schemas": { "record": {
"type": "string",
"description": "dummy",
"pattern": "^[a-z0-9\-]+$",
"example": "supplier"
}}}}

and tested

  • "$ref": "components/schemas/type.json#/components/schemas/record"

But no luck..

Original comment
After some debuging I discovered that in asyncapi schema references use the $schema keyword instead of $ref that is used in openapi.
It would be nice to have a lint check and better information when discovering this problem.

Thanks

@marianobntz marianobntz changed the title better error handling when $ref is used instead of $schema in asyncapi better error handling when $ref references an external file in asyncapi May 2, 2024
@tatomyr
Copy link
Contributor

tatomyr commented May 3, 2024

Hi @marianobntz, this looks like a bug. Where did you put the $ref?

@marianobntz
Copy link
Author

Tried to put the $ref in a message payload directly in a channel, inside a reusable component under components/messages with no luck.

@marianobntz
Copy link
Author

weird thing is that the lint command supports the external ref, it is just the bundle command who breaks...

@lornajane
Copy link
Collaborator

I'm sorry, only the lint command supports AsyncAPI (v2.6) at the moment. Bundle doesn't have AsyncAPI support yet (for any version)

@marianobntz
Copy link
Author

ok.. can I change the issue title to "support bundle for asyncapi documents?" 😄

bundle actually works if you do not use the external $ref

@tatomyr
Copy link
Contributor

tatomyr commented May 10, 2024

bundle actually works if you do not use the external $ref

It also works for external $refs from some specific places (like channel servers and message examples). So at first I thought the bundle command was implemented 🙈. But yes, it needs to be implemented separately.

@tatomyr tatomyr added the p2 label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants