Skip to content

Commit e59fbe6

Browse files
committed
chore: add test cases for references in OpenApi docs
1 parent a01f21d commit e59fbe6

15 files changed

+474
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
openapi: 3.1.0
2+
info:
3+
title: OpenAPI document containing reusable components
4+
version: 1.0.0
5+
components:
6+
schemas:
7+
person:
8+
type: object
9+
properties:
10+
name:
11+
type: string
12+
address:
13+
type: object
14+
properties:
15+
street:
16+
type: string
17+
city:
18+
type: string
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Example of reference object in a component object
4+
version: 1.0.0
5+
paths:
6+
/item:
7+
get:
8+
security:
9+
- customapikey: []
10+
components:
11+
securitySchemes:
12+
customapikey:
13+
$ref: ./customApiKey.yaml#/components/securityschemes/customapikey
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Example of reference object pointing to a parameter
4+
version: 1.0.0
5+
paths: {}
6+
components:
7+
securitySchemes:
8+
customapikey:
9+
type: apiKey
10+
name: x-api-key
11+
in: header
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# file for examples (examples.yaml)
2+
openapi: 3.1.0
3+
info:
4+
title: OpenAPI document containing examples for reuse
5+
version: 1.0.0
6+
components:
7+
examples:
8+
item-list:
9+
value:
10+
- name: thing
11+
description: a thing
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Reference to an external OpenApi document component
4+
version: 1.0.0
5+
paths:
6+
/person/{id}:
7+
get:
8+
responses:
9+
200:
10+
description: ok
11+
content:
12+
application/json:
13+
schema:
14+
$ref: 'OAS-schemas.yaml#/components/schemas/person/properties/address'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Example of reference object pointing to an example object in an OpenAPI document
4+
version: 1.0.0
5+
paths:
6+
/items:
7+
get:
8+
responses:
9+
'200':
10+
description: sample description
11+
content:
12+
application/json:
13+
examples:
14+
item-list:
15+
$ref: './examples.yaml#/components/examples/item-list'
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Example of reference object pointing to a parameter
4+
version: 1.0.0
5+
paths:
6+
/item:
7+
get:
8+
parameters:
9+
- $ref: '#/components/parameters/size'
10+
components:
11+
parameters:
12+
size:
13+
schema:
14+
type: number
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Reference an internal component using id
4+
version: 1.0.0
5+
paths:
6+
/person/{id}:
7+
get:
8+
responses:
9+
200:
10+
description: ok
11+
content:
12+
application/json:
13+
schema:
14+
$ref: 'https://schemas.acme.org/person'
15+
components:
16+
schemas:
17+
person:
18+
$id: 'https://schemas.acme.org/person'
19+
type: object
20+
properties:
21+
name:
22+
type: string
23+
address:
24+
type: object
25+
properties:
26+
street:
27+
type: string
28+
city:
29+
type: string
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Reference to an internal component
4+
version: 1.0.0
5+
paths:
6+
/person/{id}:
7+
get:
8+
responses:
9+
200:
10+
description: ok
11+
content:
12+
application/json:
13+
schema:
14+
$ref: '#/components/schemas/person'
15+
/person/{id}/address:
16+
get:
17+
responses:
18+
200:
19+
description: ok
20+
content:
21+
application/json:
22+
schema:
23+
$ref: '#/components/schemas/person/properties/address'
24+
components:
25+
schemas:
26+
person:
27+
type: object
28+
properties:
29+
name:
30+
type: string
31+
address:
32+
type: object
33+
properties:
34+
street:
35+
type: string
36+
city:
37+
type: string
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
openapi: 3.1.0
2+
info:
3+
title: OpenAPI document containing examples for reuse
4+
version: 1.0.0
5+
components:
6+
schemas:
7+
a:
8+
type:
9+
- object
10+
- 'null'
11+
properties:
12+
b:
13+
type:
14+
- object
15+
- 'null'
16+
properties:
17+
c:
18+
type:
19+
- object
20+
- 'null'
21+
properties:
22+
b:
23+
$ref: '#/properties/b'

0 commit comments

Comments
 (0)