Skip to content

Commit 0a4242f

Browse files
authored
Merge pull request #208 from znsio/message_of_array_type_with_an_example_parse_issue_fix
parse message payload of any type other than map of String to Object
2 parents 36a3344 + 3dfe458 commit 0a4242f

File tree

4 files changed

+168
-1
lines changed

4 files changed

+168
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This action is centrally managed in https://github.com/asyncapi/.github/
2+
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo
3+
4+
name: Trigger MAINTAINERS.yaml file update
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
paths:
10+
# Check all valid CODEOWNERS locations:
11+
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-location
12+
- 'CODEOWNERS'
13+
- '.github/CODEOWNERS'
14+
- '.docs/CODEOWNERS'
15+
16+
jobs:
17+
trigger-maintainers-update:
18+
name: Trigger updating MAINTAINERS.yaml because of CODEOWNERS change
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Repository Dispatch
23+
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # https://github.com/peter-evans/repository-dispatch/releases/tag/v3.0.0
24+
with:
25+
# The PAT with the 'public_repo' scope is required
26+
token: ${{ secrets.GH_TOKEN }}
27+
repository: ${{ github.repository_owner }}/community
28+
event-type: trigger-maintainers-update

asyncapi-core/src/main/java/com/asyncapi/v3/_0_0/model/channel/message/MessageExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class MessageExample extends ExtendableObject {
3030
* The value of this field MUST validate against the Message {@link Message} payload field.
3131
*/
3232
@Nullable
33-
public Map<String, Object> payload;
33+
public Object payload;
3434

3535
/**
3636
* A machine-friendly name.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package com.asyncapi.examples.v3._0_0
2+
3+
import com.asyncapi.schemas.asyncapi.Reference
4+
import com.asyncapi.v3._0_0.model.channel.Channel
5+
import com.asyncapi.v3._0_0.model.channel.message.Message
6+
import com.asyncapi.v3._0_0.model.component.Components
7+
import com.asyncapi.v3._0_0.model.info.Info
8+
import com.asyncapi.v3._0_0.model.operation.Operation
9+
import com.asyncapi.v3._0_0.model.operation.OperationAction
10+
import com.asyncapi.schemas.asyncapi.AsyncAPISchema
11+
import com.asyncapi.v3._0_0.model.channel.message.MessageExample
12+
13+
class ArrayAsMessageAsyncAPI: AbstractExampleValidationTest() {
14+
15+
override fun specificationLocation(): String = "/examples/v3.0.0/message-of-array-type-asyncapi.yml"
16+
17+
override fun expectedInfo(): Info {
18+
return Info.builder()
19+
.title("Message of array type example")
20+
.version("1.0.0")
21+
.build()
22+
}
23+
24+
override fun expectedServers(): Map<String, Any> = emptyMap()
25+
26+
override fun expectedChannels(): Map<String, Any> {
27+
return mapOf(
28+
Pair("test",
29+
Channel.builder()
30+
.address("test")
31+
.messages(mapOf(
32+
Pair("testMessages",
33+
Reference("#/components/messages/testMessages")
34+
)
35+
))
36+
.build()
37+
)
38+
)
39+
}
40+
41+
override fun expectedOperations(): Map<String, Any> {
42+
return mapOf(
43+
Pair("onTestMsg",
44+
Operation.builder()
45+
.action(OperationAction.RECEIVE)
46+
.channel(Reference("#/channels/test"))
47+
.messages(listOf(Reference("#/channels/test/messages/testMessages")))
48+
.build()
49+
)
50+
)
51+
}
52+
53+
override fun expectedComponents(): Components {
54+
return Components.builder()
55+
.messages(mapOf(
56+
Pair("testMessages",
57+
Message.builder()
58+
.payload(
59+
Reference("#/components/schemas/objectWithKeyArray")
60+
)
61+
.examples(
62+
listOf(
63+
MessageExample.builder().name("example1").payload(
64+
listOf(
65+
mapOf("key" to "value1"),
66+
mapOf("key" to "value2")
67+
)
68+
).build(),
69+
MessageExample.builder().name("example2").payload(
70+
listOf(
71+
mapOf("key" to "value3")
72+
)
73+
).build()
74+
)
75+
)
76+
.build()
77+
)
78+
))
79+
.schemas(mapOf(
80+
Pair(
81+
"objectWithKeyArray", AsyncAPISchema.builder()
82+
.type("array")
83+
.items(
84+
AsyncAPISchema.builder()
85+
.type("object")
86+
.properties(
87+
mapOf(
88+
Pair("key", AsyncAPISchema.builder().type("string").build())
89+
)
90+
)
91+
.build()
92+
)
93+
.build()
94+
)
95+
))
96+
.build()
97+
}
98+
99+
}
100+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
asyncapi: 3.0.0
2+
info:
3+
title: Message of array type example
4+
version: 1.0.0
5+
channels:
6+
test:
7+
address: test
8+
messages:
9+
testMessages:
10+
$ref: '#/components/messages/testMessages'
11+
operations:
12+
onTestMsg:
13+
action: receive
14+
channel:
15+
$ref: '#/channels/test'
16+
messages:
17+
- $ref: '#/channels/test/messages/testMessages'
18+
components:
19+
messages:
20+
testMessages:
21+
payload:
22+
$ref: '#/components/schemas/objectWithKeyArray'
23+
examples:
24+
- name: example1
25+
payload:
26+
- key: "value1"
27+
- key: "value2"
28+
- name: example2
29+
payload:
30+
- key: "value3"
31+
schemas:
32+
objectWithKeyArray:
33+
type: array
34+
items:
35+
type: object
36+
properties:
37+
key:
38+
type: string
39+

0 commit comments

Comments
 (0)