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

[FEATURE] Expose custom bindings #203

Open
2 tasks done
rossdanderson opened this issue Aug 16, 2024 · 2 comments
Open
2 tasks done

[FEATURE] Expose custom bindings #203

rossdanderson opened this issue Aug 16, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@rossdanderson
Copy link

rossdanderson commented Aug 16, 2024

Why do we need this improvement?

From the documentation https://www.asyncapi.com/docs/reference/specification/v3.0.0#channelBindingsObject - it appears that the Binding Object should be extendable.
When deserializing a specification the map contains a null Object in the getBindings map which, as someone wanting to produce a custom binding, makes life a bit more difficult.

How will this change help?

A user of the library will be able to access their binding extensions, and deserialize them to the appropriate type more simply.

Screenshots

channels:
  fxConfig:
    address: /PRIVATE/FX/CONFIG
    bindings:
      x-datasource:
        map:
          - value: "%u"
            position: 2
    description: Channel for FX user config
    messages:
      FXConfigMessage:
        $ref: "#/components/messages/FXConfig"
fun main() {
    val objectMapper = ObjectMapper(YAMLFactory())

    val api = objectMapper.readValue<AsyncAPI>(object {}::class.java.getResourceAsStream("/userconfig/asyncapi.yaml"))

    api.channels?.forEach { (channelName, channel) ->
        check(channel is Channel)

        println(channel.bindings)
    }
}

outputs:

{x-datasource=null}

How could it be implemented/designed?

It would be nice if it provided a JsonNode, or a Map like Channel#getExtensionFields in the case where it encounters an extension? It looks like this might be a simple change to ChannelBindingsDeserializer (and likely the other binding deserializers).

default: return jsonParser.readValueAs(JsonNode.class);

I do not know if this is a breaking change or not as there may be code that depends on binding extensions being null in order to ignore them.

🚧 Breaking changes

Yes

👀 Have you checked for similar open issues?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue?

Yes I am willing to submit a PR!

@rossdanderson rossdanderson added the enhancement New feature or request label Aug 16, 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.

@Pakisan
Copy link
Member

Pakisan commented Aug 21, 2024

@rossdanderson hi! Thanks, will check your proposal, on weekends

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants