asyncapi / asyncapi/spec

Message Identification when oneOf is expected

Open
#1,095 6 comments 0 reactions 0 assignees View on GitHub
❔ Question stale
Dominant language
JavaScript
Stars
5.3k
Forks
382
Avg merge
7m
Merged PRs (30d)
4

Description

I have an asyncapi, similar to the one below. Is there a standard way to identify the message that we receive in the channel?

For instance, In the below example, how to identify the message sent on test2 channel? How do we know if it's objectWithKey or objectWithKey2?

```yaml
asyncapi: 3.0.0
info:
title: OneOf example
version: 1.0.0
channels:
test:
address: test
messages:
testMessages:
$ref: '#/components/messages/testMessages'
test2:
address: test2
messages:
objectWithKey:
payload:
$ref: '#/components/schemas/objectWithKey'
objectWithKey2:
payload:
$ref: '#/components/schemas/objectWithKey2'
operations:
onTestMsg:
action: receive
channel:
$ref: '#/channels/test'
messages:
- $ref: '#/channels/test/messages/testMessages'
sendTest:
action: send
channel:
$ref: '#/channels/test2'
messages:
- $ref: '#/channels/test2/messages/objectWithKey'
- $ref: '#/channels/test2/messages/objectWithKey2'
components:
messages:
testMessages:
payload:
oneOf:
- $ref: '#/components/schemas/objectWithKey'
- $ref: '#/components/schemas/objectWithKey2'
testMessage1:
payload:
$ref: '#/components/schemas/objectWithKey'
testMessage2:
payload:
$ref: '#/components/schemas/objectWithKey2'
schemas:
objectWithKey:
type: object
properties:
key:
type: string
objectWithKey2:
type: object
properties:
key2:
type: string
```

Contributor guide

Open the contributing guide

Research direction

Start with the AsyncAPI 3.0 example, especially channels.test2, operations.sendTest, and the objectWithKey/objectWithKey2 schemas. Determine whether the specification defines a standard discriminator or message-identification mechanism for oneOf payloads; done means the expected behavior and any required specification change are documented clearly.

Written by the indexing model from the issue text.

Assessment

Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.