Skip to content

Commit 48e7b43

Browse files
jonaslagonismoya
andauthored
feat: add OpenAPI 3.0 schema validation (#348)
Co-authored-by: Sergio Moya <[email protected]>
1 parent 8e127db commit 48e7b43

File tree

3 files changed

+401
-0
lines changed

3 files changed

+401
-0
lines changed

definitions/3.0.0/messageObject.json

+23
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,29 @@
236236
}
237237
}
238238
}
239+
},
240+
{
241+
"if": {
242+
"required": [
243+
"schemaFormat"
244+
],
245+
"properties": {
246+
"schemaFormat": {
247+
"enum": [
248+
"application/vnd.oai.openapi;version=3.0.0",
249+
"application/vnd.oai.openapi+json;version=3.0.0",
250+
"application/vnd.oai.openapi+yaml;version=3.0.0"
251+
]
252+
}
253+
}
254+
},
255+
"then": {
256+
"properties": {
257+
"payload": {
258+
"$ref": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json"
259+
}
260+
}
261+
}
239262
}
240263
],
241264
"$schema": "http://json-schema.org/draft-07/schema#",
+288
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json",
4+
"type": "object",
5+
"definitions": {
6+
"ExternalDocumentation": {
7+
"type": "object",
8+
"required": [
9+
"url"
10+
],
11+
"properties": {
12+
"description": {
13+
"type": "string"
14+
},
15+
"url": {
16+
"type": "string",
17+
"format": "uri-reference"
18+
}
19+
},
20+
"patternProperties": {
21+
"^x-": {}
22+
},
23+
"additionalProperties": false
24+
},
25+
"Discriminator": {
26+
"type": "object",
27+
"required": [
28+
"propertyName"
29+
],
30+
"properties": {
31+
"propertyName": {
32+
"type": "string"
33+
},
34+
"mapping": {
35+
"type": "object",
36+
"additionalProperties": {
37+
"type": "string"
38+
}
39+
}
40+
}
41+
},
42+
"Reference": {
43+
"type": "object",
44+
"required": [
45+
"$ref"
46+
],
47+
"patternProperties": {
48+
"^\\$ref$": {
49+
"type": "string",
50+
"format": "uri-reference"
51+
}
52+
}
53+
},
54+
"XML": {
55+
"type": "object",
56+
"properties": {
57+
"name": {
58+
"type": "string"
59+
},
60+
"namespace": {
61+
"type": "string",
62+
"format": "uri"
63+
},
64+
"prefix": {
65+
"type": "string"
66+
},
67+
"attribute": {
68+
"type": "boolean",
69+
"default": false
70+
},
71+
"wrapped": {
72+
"type": "boolean",
73+
"default": false
74+
}
75+
},
76+
"patternProperties": {
77+
"^x-": {}
78+
},
79+
"additionalProperties": false
80+
}
81+
},
82+
"properties": {
83+
"title": {
84+
"type": "string"
85+
},
86+
"multipleOf": {
87+
"type": "number",
88+
"exclusiveMinimum": 0
89+
},
90+
"maximum": {
91+
"type": "number"
92+
},
93+
"exclusiveMaximum": {
94+
"type": "boolean",
95+
"default": false
96+
},
97+
"minimum": {
98+
"type": "number"
99+
},
100+
"exclusiveMinimum": {
101+
"type": "boolean",
102+
"default": false
103+
},
104+
"maxLength": {
105+
"type": "integer",
106+
"minimum": 0
107+
},
108+
"minLength": {
109+
"type": "integer",
110+
"minimum": 0,
111+
"default": 0
112+
},
113+
"pattern": {
114+
"type": "string",
115+
"format": "regex"
116+
},
117+
"maxItems": {
118+
"type": "integer",
119+
"minimum": 0
120+
},
121+
"minItems": {
122+
"type": "integer",
123+
"minimum": 0,
124+
"default": 0
125+
},
126+
"uniqueItems": {
127+
"type": "boolean",
128+
"default": false
129+
},
130+
"maxProperties": {
131+
"type": "integer",
132+
"minimum": 0
133+
},
134+
"minProperties": {
135+
"type": "integer",
136+
"minimum": 0,
137+
"default": 0
138+
},
139+
"required": {
140+
"type": "array",
141+
"items": {
142+
"type": "string"
143+
},
144+
"minItems": 1,
145+
"uniqueItems": true
146+
},
147+
"enum": {
148+
"type": "array",
149+
"items": true,
150+
"minItems": 1,
151+
"uniqueItems": false
152+
},
153+
"type": {
154+
"type": "string",
155+
"enum": [
156+
"array",
157+
"boolean",
158+
"integer",
159+
"number",
160+
"object",
161+
"string"
162+
]
163+
},
164+
"not": {
165+
"oneOf": [
166+
{
167+
"$ref": "#"
168+
},
169+
{
170+
"$ref": "#/definitions/Reference"
171+
}
172+
]
173+
},
174+
"allOf": {
175+
"type": "array",
176+
"items": {
177+
"oneOf": [
178+
{
179+
"$ref": "#"
180+
},
181+
{
182+
"$ref": "#/definitions/Reference"
183+
}
184+
]
185+
}
186+
},
187+
"oneOf": {
188+
"type": "array",
189+
"items": {
190+
"oneOf": [
191+
{
192+
"$ref": "#"
193+
},
194+
{
195+
"$ref": "#/definitions/Reference"
196+
}
197+
]
198+
}
199+
},
200+
"anyOf": {
201+
"type": "array",
202+
"items": {
203+
"oneOf": [
204+
{
205+
"$ref": "#"
206+
},
207+
{
208+
"$ref": "#/definitions/Reference"
209+
}
210+
]
211+
}
212+
},
213+
"items": {
214+
"oneOf": [
215+
{
216+
"$ref": "#"
217+
},
218+
{
219+
"$ref": "#/definitions/Reference"
220+
}
221+
]
222+
},
223+
"properties": {
224+
"type": "object",
225+
"additionalProperties": {
226+
"oneOf": [
227+
{
228+
"$ref": "#"
229+
},
230+
{
231+
"$ref": "#/definitions/Reference"
232+
}
233+
]
234+
}
235+
},
236+
"additionalProperties": {
237+
"oneOf": [
238+
{
239+
"$ref": "#"
240+
},
241+
{
242+
"$ref": "#/definitions/Reference"
243+
},
244+
{
245+
"type": "boolean"
246+
}
247+
],
248+
"default": true
249+
},
250+
"description": {
251+
"type": "string"
252+
},
253+
"format": {
254+
"type": "string"
255+
},
256+
"default": true,
257+
"nullable": {
258+
"type": "boolean",
259+
"default": false
260+
},
261+
"discriminator": {
262+
"$ref": "#/definitions/Discriminator"
263+
},
264+
"readOnly": {
265+
"type": "boolean",
266+
"default": false
267+
},
268+
"writeOnly": {
269+
"type": "boolean",
270+
"default": false
271+
},
272+
"example": true,
273+
"externalDocs": {
274+
"$ref": "#/definitions/ExternalDocumentation"
275+
},
276+
"deprecated": {
277+
"type": "boolean",
278+
"default": false
279+
},
280+
"xml": {
281+
"$ref": "#/definitions/XML"
282+
}
283+
},
284+
"patternProperties": {
285+
"^x-": true
286+
},
287+
"additionalProperties": false
288+
}

0 commit comments

Comments
 (0)