asyncapi / asyncapi/spec

Channel object have no Traits field

Open
#1,219 0 comments 0 reactions 0 assignees View on GitHub
💭 Strawman (RFC 0)
Dominant language
JavaScript
Stars
5.3k
Forks
382
Avg merge
7m
Merged PRs (30d)
4

Description

[Channel object](https://www.asyncapi.com/docs/reference/specification/v3.1.0#channelObject) have no `traits` field:
- it makes it difficult to compose channels with common definitions, specifically channel binding definitions that are by their definition not composable
- this is not consistent with other asyncapi building blocks like Servers, Messages, Operations

The proposal is to add `traits` object in the same fashion as other building blocks

## Describe the solution you'd like

Add a **Channel Trait Object** and a `traits` field to the Channel Object, mirroring Operation Traits and Message Traits exactly:

- A `traits` array on the Channel Object.
- A `channelTraits` map under the Components Object for reuse.
- The same trait merge mechanism already defined for operations and messages. Traits apply in order; the Channel Object's own values take precedence. The merged result MUST be a valid Channel Object.
The Channel Trait Object carries the composable subset of channel fields (everything except the channel identity fields `address` and `messages`, and `traits` itself).


### Example: compose Kafka bindings without exploding combinations

```yaml
components:
channelTraits:
kafkaReplicated:
bindings:
kafka:
partitions: 6
replicas: 3
kafkaCompacted:
bindings:
kafka:
topicConfiguration:
cleanup.policy: [compact]

channels:
userSignedUp:
address: user.signedup
traits:
- $ref: '#/components/channelTraits/kafkaReplicated'
- $ref: '#/components/channelTraits/kafkaCompacted'
messages:
userSignedUp:
$ref: '#/components/messages/UserSignedUp'
```

Two orthogonal binding profiles compose into one channel instead of requiring a `replicated-compacted` channel definition. Add a third axis (e.g. retention) and you add one trait, not a multiplied set of channels.

## Champion

@ivangsa — will drive the proposal PR, JSON Schema changes, and parser implementation.

Contributor guide

Open the contributing guide

Research direction

Start with the Channel Object and Components Object sections of the AsyncAPI specification, then compare the existing Operation Traits and Message Traits definitions and merge rules. Review the JSON Schema and parser areas mentioned in the issue. Done means Channel Trait Objects, reusable channelTraits, ordered merging, and validation of the merged Channel Object are specified and implemented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.