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

AsyncAPI version 2.6.0 is not supported #1133

Open
AceTheCreator opened this issue Apr 13, 2024 · 13 comments
Open

AsyncAPI version 2.6.0 is not supported #1133

AceTheCreator opened this issue Apr 13, 2024 · 13 comments

Comments

@AceTheCreator
Copy link

When using version 2.6.0 of the AsyncAPI document in the Microcks UI, I keep getting the following error: Error: Version 2.6.0 is not supported.

Any idea why?

Copy link

👋 @AceTheCreator

Welcome to the Microcks community! 💖

Thanks and congrats 🎉 for opening your first issue here! Be sure to follow the issue template or please update it accordingly.

📢 If you're using Microcks in your organization, please add your company name to this list. 🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

If you need to know why and how to add yourself to the list, please read the blog post "Join the Microcks Adopters list and Empower the vibrant open source Community 🙌"

Hope you have a great time there!

🌟 ~~~~~~~~~ 🌟

📢 If you like Microcks, please ⭐ star ⭐ our repo to support it!

🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

@lbroudoux
Copy link
Member

lbroudoux commented Apr 13, 2024

Thanks for raising this issue @AceTheCreator!

You're right: I can reproduce the same error. It's the AsyncAPI web component that we're using to display the documentation that throws that error message.

For AsyncAPI 2.x, we're using https://unpkg.com/@asyncapi/[email protected]/lib/asyncapi-web-component.js web component. It seems to work correctly for AsyncAPI files from 2.0 to 2.4 (didn't try with 2.5 though).

For AsyncAPI 3.x, we're using https://unpkg.com/@asyncapi/[email protected]/lib/asyncapi-web-component.js component. It works with our samples.

Maybe there's a fresher 0.x release of this asyncapi-web-component.js that could support 2.6.0 specification? Will have a look at it.

@lbroudoux
Copy link
Member

lbroudoux commented Apr 13, 2024

I did some quick tests, and it appears that the latest 1.4.x release of the component supports the 2.6.0 version of the spec, but it fails to render previous versions of the spec with no information message.

We'd probably adjust our rendering criterion for documentation with:

  • < 2.6 => render with version 0.24.23 of the component
  • >= 2.6 => render with version 1.4.5 of the component

Do you know who could help on this and confirm that versions before 2.6 are no longer supported but 1.x versions of the react component?

@AceTheCreator
Copy link
Author

I did some quick tests, and it appears that the latest 1.4.x release of the component supports the 2.6.0 version of the spec, but it fails to render previous versions of the spec with no information message.

We'd probably adjust our rendering criterion for documentation with:

  • < 2.6 => render with version 0.24.23 of the component
  • >= 2.6 => render with version 1.4.5 of the component

Do you know who could help on this and confirm that versions before 2.6 are no longer supported but 1.x versions of the react component?

I'll take a look at the react-component and write back!

@AceTheCreator
Copy link
Author

So, I've tested the 1.x react-component, and it renders the previous version of the spec. Can you show me how you tested it @lbroudoux?

@AceTheCreator
Copy link
Author

I installed 1.4.5 of the web-component and used schema below and it rendered

{
    "asyncapi": "2.0.0",
    "info": {
      "title": "Shrek App",
      "version": "1.0.0",
      "description": "Purpose of this app is to have some fun with AsyncAPI and WebSocket and define an interface for ... Shrek.\n\n![](https://media.giphy.com/media/10Ug6rDDuG3YoU/giphy-downsized.gif)\n\nYou can use this API to chat with Shrek bot or to get updates about artifical travels to different locations.\n"
    },
    "servers": {
      "swamp": {
        "url": "ws://localhost",
        "protocol": "ws"
      }
    },
    "channels": {
      "/chat": {
        "subscribe": {
          "summary": "Client can receive chat messages.",
          "operationId": "subChatMessage",
          "message": {
            "$ref": "#/components/messages/chatMessage"
          }
        },
        "publish": {
          "summary": "Client can send chat messages.",
          "operationId": "pubChatMessage",
          "message": {
            "$ref": "#/components/messages/travelInfo"
          }
        }
      }
    },
    "components": {
      "messages": {
        "chatMessage": {
          "summary": "Message that you send or receive from chat",
          "payload": {
            "type": "string"
          }
        },
        "travelInfo": {
          "summary": "Message that contains information about travel status.",
          "examples": [
            {
              "payload": {
                "destination": "Far far away",
                "distance": "Beyond the seven mountains and seven forests",
                "arrival": "Pretty soon"
              }
            }
          ],
          "payload": {
            "type": "object",
            "properties": {
              "destination": {
                "description": "Name of travel destination.",
                "type": "string"
              },
              "distance": {
                "description": "How much distance left to the target.",
                "type": "string"
              },
              "arrival": {
                "description": "Time left to get there.",
                "type": "string"
              }
            }
          }
        }
      }
    }
  }

@lbroudoux
Copy link
Member

Hey @AceTheCreator

I've done some complementary tests and have found some interesting results... It seems that the 1.4.5 version of the components behaves a bit differently on examples rendering depending on the version of the spec. That's why I thought it was not correctly working for previous versions.

Let's me explain what I've seen.

Let's imagine I've got this AsyncAPI v3.0.0:

asyncapi: 3.0.0
id: 'urn:io.microcks.example.user-signedup'
info:
  title: User signed-up API
  version: 0.3.0
  description: Sample AsyncAPI for user signedup events
defaultContentType: application/json
channels:
  user-signedup:
    description: The topic on which user signed up events may be consumed
    messages:
      userSignedUp:
        $ref: '#/components/messages/userSignedUp'
operations:
  publishUserSignedUps:
    action: 'send'
    channel:
      $ref: '#/channels/user-signedup'
    summary: Receive information about user signed up
    messages:
      - $ref: '#/channels/user-signedup/messages/userSignedUp'
components:
  messages:
    userSignedUp:
      description: An event describing that a user just signed up
      traits:
        - $ref: '#/components/messageTraits/commonHeaders'
      headers:
        type: object
        properties:
          sentAt:
            type: string
            format: date-time
            description: Date and time when the event was sent
      payload:
        type: object
        additionalProperties: false
        properties:
          fullName:
            type: string
          email:
            type: string
            format: email
          age:
            type: integer
            minimum: 18
      examples:
        - name: laurent
          summary: Example for Laurent user
          headers:
            my-app-header: 23
            sentAt: "2020-03-11T08:03:28Z"
          payload:
            fullName: Laurent Broudoux
            email: "[email protected]"
            age: 41
        - name: john
          summary: Example for John Doe user
          headers:
            my-app-header: 24
            sentAt: "2020-03-11T08:03:38Z"
          payload:
            fullName: John Doe
            email: '{{randomEmail()}}'
            age: 36
  messageTraits:
    commonHeaders:
      headers:
        type: object
        properties:
          my-app-header:
            type: integer
            minimum: 0
            maximum: 100
      examples:
        - laurent:
            my-app-header: 21
        - yacine:
            my-app-header: 22

You see that the email address of one example ('{{randomEmail()}}') is not conformant to the spec as it should have the email format. However, rendering of documentation is ok as illustrated below:

Capture d’écran 2024-04-24 à 10 14 13

Now if I've got the same error in an AsyncAPI v2.1.0 spec:

asyncapi: '2.1.0'
id: 'urn:io.microcks.example.user-signedup'
info:
  title: User events API
  version: 0.1.0
  description: Sample AsyncAPI for user related events
  contact:
    name: Laurent Broudoux
    url: https://github.com/lbroudoux
    email: [email protected]
  license:
    name: MIT License
    url: https://opensource.org/licenses/MIT
defaultContentType: application/json
channels:
  user/events:
    subscribe:
      message:
        $ref: '#/components/messages/UserSignedUp'
components:
  messages:
    UserSignedUp:
      payload:
        type: object
        properties:
          displayName:
            type: string
            description: Name of the user
          email:
            type: string
            format: email
            description: Email of the user
      examples:
        - name: Laurent
          summary: Example for Laurent user
          payload:
            displayName: Laurent Broudoux
            email: [email protected]
        - name: Random
          summary: Example for Random user
          payload:
            displayName: '{{randomFullName()}}'
            email: '{{randomEmail()}}'

The rendering fails, only displaying a white screen with no messages, either on the developer console. Remove the format: email directive and rendering is OK.

And I think that's why we kept the older version of the web component for previous spec versions: the older version might be more permissive with older specs errors.

Obviously, consistent behavior for the different spec versions would be better. Would it be worth creating an issue for this in AsyncAPI web component? Now that efforts are focused on 3.0, I'm not sure if it's worth backporting this.... What do you think?

@AceTheCreator
Copy link
Author

I'll create an issue about it and ask for the maintainer's opinion if it'll be worth backporting this.

@AceTheCreator
Copy link
Author

It's weird, it's not supposed to render in v3 too 🤔

I'm gonna investigate it and get back

@AceTheCreator
Copy link
Author

So what i found out is that the current Spectral ruleset for v3 doesn't have a rule for validating message examples, but it does for v2, hence the reason why it breaks on v2 and not on v3

I've reported this issue, so we'll work on porting important rules from v2 to v3

@lbroudoux

@lbroudoux
Copy link
Member

Ok but as I understand, it means that it may then break v3 document representation that holds functions once the spectral rules are ported to v3...

It could be nice not to fail violently like on v2 but to just put a warning saying your example is not valid.

Otherwise people will think it's a Microcks issue. What do you think?

@AceTheCreator
Copy link
Author

Ok but as I understand, it means that it may then break v3 document representation that holds functions once the spectral rules are ported to v3...

It could be nice not to fail violently like on v2 but to just put a warning saying your example is not valid.

Otherwise people will think it's a Microcks issue. What do you think?

I'll keep a close eyes for the implementation to ensure this doesn't happen

@lbroudoux
Copy link
Member

Could you please reference here the linked issue on AsyncAPI web component? That way it'll be easier to track.

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

2 participants