Skip to content

Commit 5442937

Browse files
committed
Add comprehensive test examples
1 parent 128d240 commit 5442937

File tree

12 files changed

+643
-11
lines changed

12 files changed

+643
-11
lines changed

demo/examples/tests/allOf.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,6 @@ paths:
299299

300300
components:
301301
schemas:
302-
# Your existing schemas are integrated here.
303-
ExistingSchema1:
304-
type: object
305-
properties: ...
306-
307-
ExistingSchema2:
308-
type: object
309-
properties: ...
310-
311302
# New schemas for Books demonstration
312303
BookBase:
313304
type: object

demo/examples/tests/callbacks.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
openapi: 3.0.1
2+
info:
3+
title: Callback Example API
4+
description: Demonstrates callback usage.
5+
version: 1.0.0
6+
tags:
7+
- name: callbacks
8+
description: callback tests
9+
paths:
10+
/streams:
11+
post:
12+
tags:
13+
- callbacks
14+
summary: Subscribe for stream events
15+
description: |
16+
This endpoint registers for stream events.
17+
18+
Schema:
19+
```yaml
20+
callbacks:
21+
onEvent:
22+
'{$request.body#/callbackUrl}':
23+
post:
24+
requestBody:
25+
description: Callback payload
26+
required: true
27+
content:
28+
application/json:
29+
schema:
30+
type: object
31+
properties:
32+
message:
33+
type: string
34+
responses:
35+
'200':
36+
description: Callback accepted
37+
```
38+
requestBody:
39+
required: true
40+
content:
41+
application/json:
42+
schema:
43+
type: object
44+
properties:
45+
callbackUrl:
46+
type: string
47+
required:
48+
- callbackUrl
49+
callbacks:
50+
onEvent:
51+
"{$request.body#/callbackUrl}":
52+
post:
53+
requestBody:
54+
description: Callback payload
55+
required: true
56+
content:
57+
application/json:
58+
schema:
59+
type: object
60+
properties:
61+
message:
62+
type: string
63+
responses:
64+
"200":
65+
description: Callback accepted
66+
responses:
67+
"201":
68+
description: Subscription created
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Conditional and Prefix Items API
4+
description: Demonstrates if/then/else and prefixItems usage.
5+
version: 1.0.0
6+
tags:
7+
- name: advanced
8+
description: conditional and array tests
9+
paths:
10+
/conditional-object:
11+
get:
12+
tags:
13+
- advanced
14+
summary: Conditional schema with if/then/else
15+
description: |
16+
This endpoint validates an object with conditional logic.
17+
18+
Schema:
19+
```yaml
20+
type: object
21+
properties:
22+
type:
23+
type: string
24+
if:
25+
properties:
26+
type:
27+
const: special
28+
then:
29+
required: [specialProp]
30+
properties:
31+
specialProp:
32+
type: string
33+
else:
34+
properties:
35+
otherProp:
36+
type: integer
37+
example:
38+
type: special
39+
specialProp: "value"
40+
```
41+
responses:
42+
"200":
43+
description: Successful response
44+
content:
45+
application/json:
46+
schema:
47+
type: object
48+
properties:
49+
type:
50+
type: string
51+
if:
52+
properties:
53+
type:
54+
const: special
55+
then:
56+
required:
57+
- specialProp
58+
properties:
59+
specialProp:
60+
type: string
61+
else:
62+
properties:
63+
otherProp:
64+
type: integer
65+
example:
66+
type: special
67+
specialProp: "value"
68+
/fixed-array:
69+
get:
70+
tags:
71+
- advanced
72+
summary: Array with prefixItems
73+
description: |
74+
This endpoint demonstrates the prefixItems feature.
75+
76+
Schema:
77+
```yaml
78+
type: array
79+
prefixItems:
80+
- type: string
81+
- type: integer
82+
items: false
83+
example:
84+
- "name"
85+
- 1
86+
```
87+
responses:
88+
"200":
89+
description: Successful response
90+
content:
91+
application/json:
92+
schema:
93+
type: array
94+
prefixItems:
95+
- type: string
96+
- type: integer
97+
items: false
98+
example:
99+
- "name"
100+
- 1

demo/examples/tests/enumDescriptions.yaml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,25 @@ paths:
1212
tags:
1313
- enumDescriptions
1414
summary: Get entities by status
15-
description: Get all entities or search by status
15+
description: |
16+
Get all entities or search by status.
17+
18+
Schema:
19+
```yaml
20+
status:
21+
in: query
22+
required: true
23+
schema:
24+
type: string
25+
enum:
26+
- active
27+
- inactive
28+
- pending
29+
x-enumDescriptions:
30+
active: The entity is active
31+
inactive: The entity is inactive
32+
pending: The entity is pending approval
33+
```
1634
parameters:
1735
- name: status
1836
in: query
@@ -39,7 +57,27 @@ paths:
3957
tags:
4058
- enumDescriptions
4159
summary: Get entities by multiple status
42-
description: Get all entities or search by multiple status
60+
description: |
61+
Get all entities or search by multiple status.
62+
63+
Schema:
64+
```yaml
65+
status:
66+
in: query
67+
required: true
68+
schema:
69+
type: array
70+
items:
71+
type: string
72+
enum:
73+
- active
74+
- inactive
75+
- pending
76+
x-enumDescriptions:
77+
active: The entity is active
78+
inactive: The entity is inactive
79+
pending: The entity is pending approval
80+
```
4381
parameters:
4482
- name: status
4583
in: query

demo/examples/tests/examples.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
openapi: 3.0.2
2+
info:
3+
title: Multiple Examples API
4+
description: Demonstrates the `examples` field.
5+
version: 1.0.0
6+
tags:
7+
- name: examples
8+
description: examples tests
9+
paths:
10+
/color:
11+
get:
12+
tags:
13+
- examples
14+
summary: Parameter with multiple examples
15+
description: |
16+
Provides color information.
17+
18+
Schema:
19+
```yaml
20+
parameters:
21+
- name: palette
22+
in: query
23+
schema:
24+
type: string
25+
examples:
26+
primary:
27+
value: red
28+
secondary:
29+
value: blue
30+
```
31+
parameters:
32+
- name: palette
33+
in: query
34+
schema:
35+
type: string
36+
examples:
37+
primary:
38+
value: red
39+
secondary:
40+
value: blue
41+
responses:
42+
"200":
43+
description: OK
44+
content:
45+
application/json:
46+
schema:
47+
type: object
48+
properties:
49+
palette:
50+
type: string
51+
examples:
52+
primary:
53+
value:
54+
palette: red
55+
secondary:
56+
value:
57+
palette: blue
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
openapi: 3.0.3
2+
info:
3+
title: Format Strings API
4+
description: Demonstrates various string formats.
5+
version: 1.0.0
6+
tags:
7+
- name: formats
8+
description: format tests
9+
paths:
10+
/string-formats:
11+
get:
12+
tags:
13+
- formats
14+
summary: Strings with format validation
15+
description: |
16+
This endpoint returns strings in different formats.
17+
18+
Schema:
19+
```yaml
20+
type: object
21+
properties:
22+
uuid:
23+
type: string
24+
format: uuid
25+
email:
26+
type: string
27+
format: email
28+
example:
29+
uuid: "123e4567-e89b-12d3-a456-426614174000"
30+
31+
```
32+
responses:
33+
"200":
34+
description: Successful response
35+
content:
36+
application/json:
37+
schema:
38+
type: object
39+
properties:
40+
uuid:
41+
type: string
42+
format: uuid
43+
email:
44+
type: string
45+
format: email
46+
example:
47+
uuid: "123e4567-e89b-12d3-a456-426614174000"
48+

0 commit comments

Comments
 (0)