studio icon indicating copy to clipboard operation
studio copied to clipboard

Not possible to add message examples when references are used

Open grahambull-newday opened this issue 1 year ago • 1 comments

Describe the bug

It's not possible to add message examples when references are used. I'm pretty sure the JSON below meets the AsyncAPI specs.

How to Reproduce

Here's a complete example that, when pasted into the studio, gives 4 errors (NOT SUPPORTED: keyword "id", use "$id" for schema ID) and some warnings (ignore these). The output is from asyncapi/saunter, integrated into a C# web app, but with names changed. The only real change is the additional of the examples block in the message. I'm pretty sure it's all valid, according to the spec. Saunter outputs the references used in the message's definition.

{
  "asyncapi": "2.4.0",
  "info": {
    "title": "Title",
    "version": "1.0",
    "description": "Description"
  },
  "defaultContentType": "application/json",
  "channels": {
    "channel1": {
      "publish": {
        "operationId": "Login",
        "message": {
          "$ref": "#/components/messages/loginMessage"
        }
      }
    }
  },
  "components": {
    "schemas": {
      "loginEvent": {
        "id": "loginEvent",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "username": {
            "type": "string"
          },
          "brand": {
            "type": "string"
          }
        }
      },
      "messageHeaders": {
        "id": "messageHeaders",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "correlationId": {
            "type": "string"
          }
        }
      }
    },
    "messages": {
      "loginEvent": {
        "messageId": "loginMessage",
        "headers": {
          "$ref": "#/components/schemas/messageHeaders"
        },
        "payload": {
          "$ref": "#/components/schemas/loginEvent"
        },
        "name": "loginEvent",
        "title": "Login Message",
        "examples": [
          {
            "name": "loginMessage",
            "headers": {
              "correlationId": "123456"
            },
            "payload": {
              "username": "johnsmith",
              "brand": "brandname"
            }
          }
        ]
      }
    }
  }
}

Errors: image

Expected behavior

No errors when the studio validates the above JSON, and the studio correctly renders the document.

grahambull-newday avatar Aug 30 '24 08:08 grahambull-newday

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.

github-actions[bot] avatar Aug 30 '24 08:08 github-actions[bot]

Is this issue, active currently to work on !

rohithyarramala avatar Dec 06 '24 08:12 rohithyarramala

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar Apr 06 '25 00:04 github-actions[bot]