Skip to content

[BUG] operation.messages() containing ALL messages instead of the messages defined for the operation #1093

Description

@ctataryn

Describe the bug.

I have a 3.0.0 schema that looks like this:

asyncapi: 3.0.0
info:
  title: My Sample Schema
  version: 1.0.0
  description: A schema depicting an issue with operation.messages()
servers:
  production:
    host: myhost.com
    protocol: ws
    pathname: /ws
    description: A Websocket Server
channels:
  someChannel:
    address: someChannel
    description: A Channel
    messages:
      publish.Message1:
        $ref: "#/components/messages/PublishOnlyMessage1"
      publish.Message2:
        $ref: "#/components/messages/PublishOnlyMessage2"
operations:
  someChannel.publish:
    action: send
    channel:
      $ref: "#/channels/someChannel"
    messages:
      - $ref: "#/channels/someChannel/messages/publish.Message1"
      - $ref: "#/channels/someChannel/messages/publish.Message2"
  someChannel.subscribe:
    action: receive
    channel:
      $ref: "#/channels/someChannel"
components:
  messages:
    PublishOnlyMessage1:
      name: PublishOnlyMessage1
      payload:
        type: object
        additionalProperties: false
        properties:
          message1Text:
            type: string
    PublishOnlyMessage2:
      name: PublishOnlyMessage2
      payload:
        type: object
        additionalProperties: false
        properties:
          message2Text:
            type: string

It is my understanding that the someChannel.publish operation should contain two messages: PublishOnlyMessage1 and PublishOnlyMessage2, however the someChannel.subscribe operation should contain NO messages.

In reality however, both operations contain both messages. Here's a screenshot where I placed a breakpoin in Operation.js and each time it was hit, I inspected the values of operation.action() and operation.messages():

Image

You can see that for both operations, the messages() contain both messages. This is also evident from the markdown file that is generated.

Expected behavior

Only the someChannel.publish operation should list out both messages, the someChannel.subscribe operation should not generate any messages.

However, perhaps my misunderstanding about the relationships between operations, channels and messages.

Screenshots

Image

How to Reproduce

  1. Add the schema file included above
  2. Run npm run dev
  3. Checkout the test/output/asyncapi/md file

🖥️ Device Information [optional]

  • Operating System (OS): Windows 11, WSL2, Ubuntu 24.04.2 LTS
  • Browser:
  • Browser Version:

👀 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 ?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions