Skip to content

Commit ea44142

Browse files
committed
test: add schema.examples test cases
Adds test file demonstrating OpenAPI 3.1 schema.examples array support: - Schema-level examples array - Property-level examples arrays
1 parent ab48da0 commit ea44142

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed
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: Schema Examples API (OAS 3.1)
4+
description: |
5+
Demonstrates OpenAPI 3.1 schema.examples array support.
6+
The example generator should use the first item from the examples array
7+
when generating request/response examples.
8+
version: 1.0.0
9+
tags:
10+
- name: schemaExamples
11+
description: OpenAPI 3.1 schema.examples tests
12+
paths:
13+
/schema-examples:
14+
post:
15+
tags:
16+
- schemaExamples
17+
summary: Schema with examples array
18+
description: |
19+
The request body schema uses `examples` (array) instead of `example` (singular).
20+
The API Explorer should show the first example from the array.
21+
22+
Schema:
23+
```yaml
24+
schema:
25+
type: object
26+
properties:
27+
name:
28+
type: string
29+
status:
30+
type: string
31+
examples:
32+
- name: "John Doe"
33+
status: "active"
34+
- name: "Jane Smith"
35+
status: "pending"
36+
```
37+
requestBody:
38+
required: true
39+
content:
40+
application/json:
41+
schema:
42+
type: object
43+
properties:
44+
name:
45+
type: string
46+
status:
47+
type: string
48+
examples:
49+
- name: "John Doe"
50+
status: "active"
51+
- name: "Jane Smith"
52+
status: "pending"
53+
responses:
54+
"200":
55+
description: Success
56+
content:
57+
application/json:
58+
schema:
59+
type: object
60+
properties:
61+
id:
62+
type: integer
63+
message:
64+
type: string
65+
examples:
66+
- id: 1
67+
message: "Created successfully"
68+
- id: 2
69+
message: "Updated successfully"
70+
71+
/property-examples:
72+
post:
73+
tags:
74+
- schemaExamples
75+
summary: Properties with examples arrays
76+
description: |
77+
Individual properties use `examples` (array) instead of `example`.
78+
The generated example should use the first item from each property's examples array.
79+
requestBody:
80+
required: true
81+
content:
82+
application/json:
83+
schema:
84+
type: object
85+
properties:
86+
email:
87+
type: string
88+
format: email
89+
examples:
90+
91+
92+
role:
93+
type: string
94+
examples:
95+
- "user"
96+
- "admin"
97+
- "moderator"
98+
responses:
99+
"200":
100+
description: Success

0 commit comments

Comments
 (0)