Skip to content

Commit 41a83b6

Browse files
committed
Added tests
1 parent 4e3c680 commit 41a83b6

File tree

4 files changed

+253
-0
lines changed

4 files changed

+253
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#methods:
2+
# - get
3+
#flags:
4+
# - x-visibility
5+
#flagValues: []
6+
#tags:
7+
# - store
8+
# - user
9+
#operationIds:
10+
# - addPet
11+
# - findPetsByStatus
12+
unusedComponents:
13+
- schemas
14+
- parameters
15+
- examples
16+
- headers
17+
- requestBodies
18+
- responses
19+
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Test API
4+
version: 1.0.0
5+
paths:
6+
/pets:
7+
get:
8+
summary: List all pets
9+
parameters:
10+
- $ref: '#/components/parameters/ParamUsed'
11+
responses:
12+
'200':
13+
description: A list of pets
14+
headers:
15+
X-RateLimit:
16+
$ref: '#/components/headers/HeaderUsed'
17+
content:
18+
application/json:
19+
schema:
20+
type: array
21+
items:
22+
$ref: '#/components/schemas/SchemaUsed'
23+
examples:
24+
petExample:
25+
$ref: '#/components/examples/ExampleUsed'
26+
post:
27+
summary: Add a new pet
28+
requestBody:
29+
$ref: '#/components/requestBodies/RequestBodyUsed'
30+
responses:
31+
'201':
32+
$ref: '#/components/responses/ResponseUsed'
33+
/users:
34+
get:
35+
summary: Get all users
36+
responses:
37+
'200':
38+
description: OK
39+
content:
40+
application/json:
41+
schema:
42+
# — directly referenced in a path
43+
$ref: '#/components/schemas/User'
44+
components:
45+
schemas:
46+
User:
47+
type: object
48+
properties:
49+
id:
50+
type: integer
51+
name:
52+
type: string
53+
# — Not referenced in any path.
54+
InvisibleParent:
55+
type: object
56+
properties:
57+
# ...but references another schema
58+
child:
59+
$ref: '#/components/schemas/InvisibleChild'
60+
InvisibleChild:
61+
type: object
62+
properties:
63+
foo:
64+
type: string
65+
# — used directly by /pets GET and by RequestBodyUsed
66+
SchemaUsed:
67+
type: object
68+
properties:
69+
id:
70+
type: integer
71+
# — never referenced anywhere → direct unused
72+
SchemaUnused:
73+
type: object
74+
properties:
75+
foo:
76+
type: string
77+
# — a chain of refs to test transitive removal:
78+
SchemaChain1:
79+
allOf:
80+
- $ref: '#/components/schemas/SchemaChain2'
81+
SchemaChain2:
82+
allOf:
83+
- $ref: '#/components/schemas/SchemaChain3'
84+
SchemaChain3:
85+
allOf:
86+
- $ref: '#/components/schemas/SchemaChain4'
87+
SchemaChain4:
88+
type: object
89+
properties:
90+
bar:
91+
type: boolean
92+
responses:
93+
# — used by POST /pets
94+
ResponseUsed:
95+
description: Created successfully
96+
# — never referenced → direct unused
97+
ResponseUnused:
98+
description: This one’s not used
99+
parameters:
100+
# — used by GET /pets
101+
ParamUsed:
102+
name: status
103+
in: query
104+
schema:
105+
type: string
106+
# — never referenced → direct unused
107+
ParamUnused:
108+
name: unusedParam
109+
in: query
110+
schema:
111+
type: integer
112+
examples:
113+
# — used in GET /pets response
114+
ExampleUsed:
115+
summary: A single pet
116+
value:
117+
id: 1
118+
# — never referenced → direct unused
119+
ExampleUnused:
120+
summary: Not used
121+
value:
122+
hello: world
123+
requestBodies:
124+
# — used by POST /pets
125+
RequestBodyUsed:
126+
description: New pet to add
127+
content:
128+
application/json:
129+
schema:
130+
$ref: '#/components/schemas/SchemaUsed'
131+
# — never referenced → direct unused
132+
RequestBodyUnused:
133+
description: Not used
134+
content:
135+
application/json:
136+
schema:
137+
type: object
138+
headers:
139+
# — used in GET /pets response
140+
HeaderUsed:
141+
description: Rate limit info
142+
schema:
143+
type: integer
144+
# — never referenced → direct unused
145+
HeaderUnused:
146+
description: Not used
147+
schema:
148+
type: string
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
verbose: true
2+
no-sort: true
3+
output: output.yaml
4+
filterFile: customFilter.yaml
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Test API
4+
version: 1.0.0
5+
paths:
6+
/pets:
7+
get:
8+
summary: List all pets
9+
parameters:
10+
- $ref: '#/components/parameters/ParamUsed'
11+
responses:
12+
'200':
13+
description: A list of pets
14+
headers:
15+
X-RateLimit:
16+
$ref: '#/components/headers/HeaderUsed'
17+
content:
18+
application/json:
19+
schema:
20+
type: array
21+
items:
22+
$ref: '#/components/schemas/SchemaUsed'
23+
examples:
24+
petExample:
25+
$ref: '#/components/examples/ExampleUsed'
26+
post:
27+
summary: Add a new pet
28+
requestBody:
29+
$ref: '#/components/requestBodies/RequestBodyUsed'
30+
responses:
31+
'201':
32+
$ref: '#/components/responses/ResponseUsed'
33+
/users:
34+
get:
35+
summary: Get all users
36+
responses:
37+
'200':
38+
description: OK
39+
content:
40+
application/json:
41+
schema:
42+
$ref: '#/components/schemas/User'
43+
components:
44+
schemas:
45+
User:
46+
type: object
47+
properties:
48+
id:
49+
type: integer
50+
name:
51+
type: string
52+
SchemaUsed:
53+
type: object
54+
properties:
55+
id:
56+
type: integer
57+
responses:
58+
ResponseUsed:
59+
description: Created successfully
60+
parameters:
61+
ParamUsed:
62+
name: status
63+
in: query
64+
schema:
65+
type: string
66+
examples:
67+
ExampleUsed:
68+
summary: A single pet
69+
value:
70+
id: 1
71+
requestBodies:
72+
RequestBodyUsed:
73+
description: New pet to add
74+
content:
75+
application/json:
76+
schema:
77+
$ref: '#/components/schemas/SchemaUsed'
78+
headers:
79+
HeaderUsed:
80+
description: Rate limit info
81+
schema:
82+
type: integer

0 commit comments

Comments
 (0)