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

Not possible to add message examples when references are used #1132

Open
grahambull-newday opened this issue Aug 30, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@grahambull-newday
Copy link

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 grahambull-newday added the bug Something isn't working label Aug 30, 2024
Copy link

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.

@immortal121
Copy link

Is this issue, active currently to work on !

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
Status: Backlog
Development

No branches or pull requests

2 participants