Skip to content

Commit 7e09fc1

Browse files
jonaslagonismoya
andauthored
feat: add core message payload validation (#352)
Co-authored-by: Sergio Moya <1083296+smoya@users.noreply.github.com>
1 parent 60ac9ed commit 7e09fc1

File tree

7 files changed

+511
-7
lines changed

7 files changed

+511
-7
lines changed

definitions/2.0.0/message.json

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,70 @@
119119
]
120120
}
121121
}
122-
}
122+
},
123+
"allOf": [
124+
{
125+
"if": {
126+
"not": {
127+
"required": [
128+
"schemaFormat"
129+
]
130+
}
131+
},
132+
"then": {
133+
"properties": {
134+
"payload": {
135+
"$ref": "http://asyncapi.com/definitions/2.0.0/schema.json"
136+
}
137+
}
138+
}
139+
},
140+
{
141+
"if": {
142+
"required": [
143+
"schemaFormat"
144+
],
145+
"properties": {
146+
"schemaFormat": {
147+
"enum": [
148+
"application/vnd.aai.asyncapi;version=2.0.0",
149+
"application/vnd.aai.asyncapi+json;version=2.0.0",
150+
"application/vnd.aai.asyncapi+yaml;version=2.0.0"
151+
]
152+
}
153+
}
154+
},
155+
"then": {
156+
"properties": {
157+
"payload": {
158+
"$ref": "http://asyncapi.com/definitions/2.0.0/schema.json"
159+
}
160+
}
161+
}
162+
},
163+
{
164+
"if": {
165+
"required": [
166+
"schemaFormat"
167+
],
168+
"properties": {
169+
"schemaFormat": {
170+
"enum": [
171+
"application/schema+json;version=draft-07",
172+
"application/schema+yaml;version=draft-07"
173+
]
174+
}
175+
}
176+
},
177+
"then": {
178+
"properties": {
179+
"payload": {
180+
"$ref": "http://json-schema.org/draft-07/schema"
181+
}
182+
}
183+
}
184+
}
185+
]
123186
}
124187
]
125188
}

definitions/2.1.0/message.json

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,73 @@
139139
]
140140
}
141141
}
142-
}
142+
},
143+
"allOf": [
144+
{
145+
"if": {
146+
"not": {
147+
"required": [
148+
"schemaFormat"
149+
]
150+
}
151+
},
152+
"then": {
153+
"properties": {
154+
"payload": {
155+
"$ref": "http://asyncapi.com/definitions/2.1.0/schema.json"
156+
}
157+
}
158+
}
159+
},
160+
{
161+
"if": {
162+
"required": [
163+
"schemaFormat"
164+
],
165+
"properties": {
166+
"schemaFormat": {
167+
"enum": [
168+
"application/vnd.aai.asyncapi;version=2.0.0",
169+
"application/vnd.aai.asyncapi+json;version=2.0.0",
170+
"application/vnd.aai.asyncapi+yaml;version=2.0.0",
171+
"application/vnd.aai.asyncapi;version=2.1.0",
172+
"application/vnd.aai.asyncapi+json;version=2.1.0",
173+
"application/vnd.aai.asyncapi+yaml;version=2.1.0"
174+
]
175+
}
176+
}
177+
},
178+
"then": {
179+
"properties": {
180+
"payload": {
181+
"$ref": "http://asyncapi.com/definitions/2.1.0/schema.json"
182+
}
183+
}
184+
}
185+
},
186+
{
187+
"if": {
188+
"required": [
189+
"schemaFormat"
190+
],
191+
"properties": {
192+
"schemaFormat": {
193+
"enum": [
194+
"application/schema+json;version=draft-07",
195+
"application/schema+yaml;version=draft-07"
196+
]
197+
}
198+
}
199+
},
200+
"then": {
201+
"properties": {
202+
"payload": {
203+
"$ref": "http://json-schema.org/draft-07/schema"
204+
}
205+
}
206+
}
207+
}
208+
]
143209
}
144210
]
145211
}

definitions/2.2.0/message.json

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,76 @@
139139
]
140140
}
141141
}
142-
}
142+
},
143+
"allOf": [
144+
{
145+
"if": {
146+
"not": {
147+
"required": [
148+
"schemaFormat"
149+
]
150+
}
151+
},
152+
"then": {
153+
"properties": {
154+
"payload": {
155+
"$ref": "http://asyncapi.com/definitions/2.2.0/schema.json"
156+
}
157+
}
158+
}
159+
},
160+
{
161+
"if": {
162+
"required": [
163+
"schemaFormat"
164+
],
165+
"properties": {
166+
"schemaFormat": {
167+
"enum": [
168+
"application/vnd.aai.asyncapi;version=2.0.0",
169+
"application/vnd.aai.asyncapi+json;version=2.0.0",
170+
"application/vnd.aai.asyncapi+yaml;version=2.0.0",
171+
"application/vnd.aai.asyncapi;version=2.1.0",
172+
"application/vnd.aai.asyncapi+json;version=2.1.0",
173+
"application/vnd.aai.asyncapi+yaml;version=2.1.0",
174+
"application/vnd.aai.asyncapi;version=2.2.0",
175+
"application/vnd.aai.asyncapi+json;version=2.2.0",
176+
"application/vnd.aai.asyncapi+yaml;version=2.2.0"
177+
]
178+
}
179+
}
180+
},
181+
"then": {
182+
"properties": {
183+
"payload": {
184+
"$ref": "http://asyncapi.com/definitions/2.2.0/schema.json"
185+
}
186+
}
187+
}
188+
},
189+
{
190+
"if": {
191+
"required": [
192+
"schemaFormat"
193+
],
194+
"properties": {
195+
"schemaFormat": {
196+
"enum": [
197+
"application/schema+json;version=draft-07",
198+
"application/schema+yaml;version=draft-07"
199+
]
200+
}
201+
}
202+
},
203+
"then": {
204+
"properties": {
205+
"payload": {
206+
"$ref": "http://json-schema.org/draft-07/schema"
207+
}
208+
}
209+
}
210+
}
211+
]
143212
}
144213
]
145214
}

definitions/2.3.0/message.json

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,79 @@
139139
]
140140
}
141141
}
142-
}
142+
},
143+
"allOf": [
144+
{
145+
"if": {
146+
"not": {
147+
"required": [
148+
"schemaFormat"
149+
]
150+
}
151+
},
152+
"then": {
153+
"properties": {
154+
"payload": {
155+
"$ref": "http://asyncapi.com/definitions/2.3.0/schema.json"
156+
}
157+
}
158+
}
159+
},
160+
{
161+
"if": {
162+
"required": [
163+
"schemaFormat"
164+
],
165+
"properties": {
166+
"schemaFormat": {
167+
"enum": [
168+
"application/vnd.aai.asyncapi;version=2.0.0",
169+
"application/vnd.aai.asyncapi+json;version=2.0.0",
170+
"application/vnd.aai.asyncapi+yaml;version=2.0.0",
171+
"application/vnd.aai.asyncapi;version=2.1.0",
172+
"application/vnd.aai.asyncapi+json;version=2.1.0",
173+
"application/vnd.aai.asyncapi+yaml;version=2.1.0",
174+
"application/vnd.aai.asyncapi;version=2.2.0",
175+
"application/vnd.aai.asyncapi+json;version=2.2.0",
176+
"application/vnd.aai.asyncapi+yaml;version=2.2.0",
177+
"application/vnd.aai.asyncapi;version=2.3.0",
178+
"application/vnd.aai.asyncapi+json;version=2.3.0",
179+
"application/vnd.aai.asyncapi+yaml;version=2.3.0"
180+
]
181+
}
182+
}
183+
},
184+
"then": {
185+
"properties": {
186+
"payload": {
187+
"$ref": "http://asyncapi.com/definitions/2.3.0/schema.json"
188+
}
189+
}
190+
}
191+
},
192+
{
193+
"if": {
194+
"required": [
195+
"schemaFormat"
196+
],
197+
"properties": {
198+
"schemaFormat": {
199+
"enum": [
200+
"application/schema+json;version=draft-07",
201+
"application/schema+yaml;version=draft-07"
202+
]
203+
}
204+
}
205+
},
206+
"then": {
207+
"properties": {
208+
"payload": {
209+
"$ref": "http://json-schema.org/draft-07/schema"
210+
}
211+
}
212+
}
213+
}
214+
]
143215
}
144216
]
145217
}

definitions/2.4.0/message.json

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,82 @@
142142
]
143143
}
144144
}
145-
}
145+
},
146+
"allOf": [
147+
{
148+
"if": {
149+
"not": {
150+
"required": [
151+
"schemaFormat"
152+
]
153+
}
154+
},
155+
"then": {
156+
"properties": {
157+
"payload": {
158+
"$ref": "http://asyncapi.com/definitions/2.4.0/schema.json"
159+
}
160+
}
161+
}
162+
},
163+
{
164+
"if": {
165+
"required": [
166+
"schemaFormat"
167+
],
168+
"properties": {
169+
"schemaFormat": {
170+
"enum": [
171+
"application/vnd.aai.asyncapi;version=2.0.0",
172+
"application/vnd.aai.asyncapi+json;version=2.0.0",
173+
"application/vnd.aai.asyncapi+yaml;version=2.0.0",
174+
"application/vnd.aai.asyncapi;version=2.1.0",
175+
"application/vnd.aai.asyncapi+json;version=2.1.0",
176+
"application/vnd.aai.asyncapi+yaml;version=2.1.0",
177+
"application/vnd.aai.asyncapi;version=2.2.0",
178+
"application/vnd.aai.asyncapi+json;version=2.2.0",
179+
"application/vnd.aai.asyncapi+yaml;version=2.2.0",
180+
"application/vnd.aai.asyncapi;version=2.3.0",
181+
"application/vnd.aai.asyncapi+json;version=2.3.0",
182+
"application/vnd.aai.asyncapi+yaml;version=2.3.0",
183+
"application/vnd.aai.asyncapi;version=2.4.0",
184+
"application/vnd.aai.asyncapi+json;version=2.4.0",
185+
"application/vnd.aai.asyncapi+yaml;version=2.4.0"
186+
]
187+
}
188+
}
189+
},
190+
"then": {
191+
"properties": {
192+
"payload": {
193+
"$ref": "http://asyncapi.com/definitions/2.4.0/schema.json"
194+
}
195+
}
196+
}
197+
},
198+
{
199+
"if": {
200+
"required": [
201+
"schemaFormat"
202+
],
203+
"properties": {
204+
"schemaFormat": {
205+
"enum": [
206+
"application/schema+json;version=draft-07",
207+
"application/schema+yaml;version=draft-07"
208+
]
209+
}
210+
}
211+
},
212+
"then": {
213+
"properties": {
214+
"payload": {
215+
"$ref": "http://json-schema.org/draft-07/schema"
216+
}
217+
}
218+
}
219+
}
220+
]
146221
}
147222
]
148223
}

0 commit comments

Comments
 (0)