docs: update Message Example payload type#1082
Conversation
According to JSON Schema headers and payload properties may be of any type
fmvilas
left a comment
There was a problem hiding this comment.
Changed my mind after thinking a bit more.
spec/asyncapi.md
Outdated
| ---|:---:|--- | ||
| <a name="messageExampleObjectHeaders"></a>headers | `Map[string, any]` | The value of this field MUST validate against the [Message Object's headers](#messageObjectHeaders) field. | ||
| <a name="messageExampleObjectPayload"></a>payload | `Map[string, any]` | The value of this field MUST validate against the [Message Object's payload](#messageObjectPayload) field. | ||
| <a name="messageExampleObjectHeaders"></a>headers | `any` | The value of this field MUST validate against the [Message Object's headers](#messageObjectHeaders) field. |
There was a problem hiding this comment.
I think the change is justified for payload as it can be an array, for instance. However, I'm not sure in which cases headers could be anything different than a map.
There was a problem hiding this comment.
@fmvilas Yep, I thought same way, but after this I re-read definitions and it may by of any type
In Message we are defining schema for payload and headers. This two properties are JSON Schema or Multi format Schema
So they can be of any defined and valid JSON Schema type - string, number, object, etc. Or Avro type
This is main reason to define headers and payload in MessageExample as any type and validate them trough it's schemas in Message object
There was a problem hiding this comment.
The definition of headers explicitly says:
Schema MUST be a map of key-value pairs.
So it can't be any, right?
There was a problem hiding this comment.
headers
IMHO headers should stay as it is. It was always like this, in previous versions too, key/value as this is who headers look like.
So they can be of any defined and valid JSON Schema type - string, number, object, etc. Or Avro type
spec is more specific in case of headers if you compare with payload
Schema MUST be a map of key-value pairs
payload
In case of payload. This is what it was before v3 which makes sense as payload is any
<a name="messageExampleObjectHeaders"></a>headers | `Map[string, any]` | The value of this field MUST validate against the [Message Object's headers](#messageObjectHeaders) field.
<a name="messageExampleObjectPayload"></a>payload | `any` | The value of this field MUST validate against the [Message Object's payload](#messageObjectPayload) field.
in v3 we introduced Multi Format Schema Object, so payload can also be payload.schema and payload.schemaFormat and definition of payload was changed from any to Multi Format Schema Object | Schema Object | Reference Object but yeah, because of Schema Object it is still basically any.
which means message payload example should also be any.
I went through #910 but I see that we were 100% focused there on the message.payload definition and Multi Format Schema Object that the change in Message Example Object Payload type was overlooked.
Rollback headers to Map[string, any]
|
|
@Pakisan please adjust the description and PR title to reflect the final scope |
|
@dalelane @smoya @char0n @GreenRover can any of you have a look |
dalelane
left a comment
There was a problem hiding this comment.
This looks fine to me - thanks
|
/rtm |
|
🎉 This PR is included in version 3.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |



According to JSON Schema
MessageExample.payloadmay be of any typeSee: