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

$ref do not work with bindings in channel in v3 #438

Closed
derberg opened this issue Oct 31, 2023 · 4 comments
Closed

$ref do not work with bindings in channel in v3 #438

derberg opened this issue Oct 31, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@derberg
Copy link
Member

derberg commented Oct 31, 2023

issue might be with any bindings, not just channel, I did not check

spec says that in channels I can also have $ref

Screenshot 2023-10-31 at 14 17 15

which makes sense as I want to have some reusable stuff in components. channelBindings

I would expect below example to work (studio direct link - btw I love new share button in studio:

asyncapi: '3.0.0'
info:
  title: MySlackBot API
  version: '1.0.0'
  description:  |
    The MySlackBot App manages popular messages in a workspace by monitoring message reaction data from Slack's Event API.
    
servers:
  ws:
    host: wss://wss-primary.slack.com/
    protocol: wss
    description: "Websocket URL generated to communicate with Slack"
channels:
  root:
    address: /
    messages:
      reactionListener: {}
      helloListener: {}
    bindings:
      $ref: "#/components/channelBindings/connectionQuery"
      
operations:
  helloListenerOperation:
    action: receive
    channel:
      $ref: "#/channels/root"
    messages: 
      - $ref: "#/channels/root/messages/helloListener"
  reactionListenerOperation:
    action: receive
    channel: 
      $ref: "#/channels/root"
    messages: 
      - $ref: "#/channels/root/messages/reactionListener"

components:
  channelBindings:
    connectionQuery:
      ws:
        query: {}

but this says is not allowed

bindings:
      $ref: "#/components/channelBindings/connectionQuery"

After so many years, I still do not feel like JSON Schema expert so can you confirm, but I think in here https://github.com/asyncapi/spec-json-schemas/blob/next-major-spec/definitions/3.0.0/channel.json#L65 we should instead have something like

"bindings": {
      "oneOf": [
        {
          "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
        },
        {
          "$ref": "http://asyncapi.com/definitions/3.0.0/channelBindingsObject.json"
        }
      ]

thoughts?

@derberg derberg added the bug Something isn't working label Oct 31, 2023
@smoya
Copy link
Member

smoya commented Nov 1, 2023

I'm from my phone so checking code is a pain, but i noticed the same happens with others like operation bindings.

Regarding your suggested solution, seems ok to me.

@fmvilas
Copy link
Member

fmvilas commented Nov 2, 2023

Yeah, I think it does make sense indeed.

@derberg
Copy link
Member Author

derberg commented Nov 7, 2023

@fmvilas @smoya PR opened: #442

@derberg
Copy link
Member Author

derberg commented Nov 30, 2023

solved in next-major-spec

@derberg derberg closed this as completed Nov 30, 2023
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
None yet
Development

No branches or pull requests

3 participants