Skip to content

Commit ca9b322

Browse files
Refactored the circular-extended tests to use external $refs rather than just internal ones. This tests a few edge cases that weren't covered before
1 parent cac28c6 commit ca9b322

16 files changed

+480
-481
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,6 @@
11
definitions:
22
person:
3-
title: person
4-
properties:
5-
name:
6-
type: string
7-
spouse:
8-
$ref: "#/definitions/person"
9-
description: >
10-
This JSON Reference has additional properties (other than $ref).
11-
This creates a new type that extends "person".
12-
pet:
13-
$ref: '#/definitions/pet'
14-
description: >
15-
This JSON Reference has additional properties (other than $ref).
16-
This creates a new type that extends "pet".
3+
$ref: definitions/person-with-spouse.yaml
174

185
pet:
19-
title: pet
20-
type: object
21-
properties:
22-
name:
23-
type: string
24-
age:
25-
type: number
26-
species:
27-
type: string
28-
enum:
29-
- cat
30-
- dog
31-
- bird
32-
- fish
6+
$ref: definitions/pet.yaml
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,9 @@
11
definitions:
22
parent:
3-
title: parent
4-
properties:
5-
name:
6-
type: string
7-
child:
8-
$ref: '#/definitions/child'
9-
description: >
10-
This JSON Reference has additional properties (other than $ref).
11-
This creates a new type that extends "child".
3+
$ref: definitions/parent-with-child.yaml
124

135
child:
14-
title: child
15-
properties:
16-
name:
17-
type: string
18-
pet:
19-
$ref: '#/definitions/pet'
20-
description: >
21-
This JSON Reference has additional properties (other than $ref).
22-
This creates a new type that extends "pet".
23-
children:
24-
description: children
25-
type: array
26-
items:
27-
$ref: '#/definitions/child'
28-
description: >
29-
This JSON Reference has additional properties (other than $ref).
30-
This creates a new type that extends "child".
6+
$ref: definitions/child-with-children.yaml
317

328
pet:
33-
title: pet
34-
type: object
35-
properties:
36-
name:
37-
type: string
38-
age:
39-
type: number
40-
species:
41-
type: string
42-
enum:
43-
- cat
44-
- dog
45-
- bird
46-
- fish
9+
$ref: definitions/pet.yaml
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,9 @@
11
definitions:
22
parent:
3-
title: parent
4-
properties:
5-
name:
6-
type: string
7-
children:
8-
type: array
9-
items:
10-
$ref: "#/definitions/child"
11-
description: >
12-
This JSON Reference has additional properties (other than $ref).
13-
This creates a new type that extends "child".
3+
$ref: definitions/parent-with-children.yaml
144

155
child:
16-
title: child
17-
properties:
18-
name:
19-
type: string
20-
pet:
21-
$ref: '#/definitions/pet'
22-
description: >
23-
This JSON Reference has additional properties (other than $ref).
24-
This creates a new type that extends "pet".
25-
parents:
26-
type: array
27-
items:
28-
$ref: "#/definitions/parent"
29-
description: >
30-
This JSON Reference has additional properties (other than $ref).
31-
This creates a new type that extends "parent".
6+
$ref: definitions/child-with-parents.yaml
327

338
pet:
34-
title: pet
35-
type: object
36-
properties:
37-
name:
38-
type: string
39-
age:
40-
type: number
41-
species:
42-
type: string
43-
enum:
44-
- cat
45-
- dog
46-
- bird
47-
- fish
9+
$ref: definitions/pet.yaml
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
definitions:
22
thing:
3-
title: thing
4-
$ref: "#/definitions/thing"
5-
description: >
6-
This JSON Reference has additional properties (other than $ref).
7-
Normally, this creates a new type that extends the referenced type,
8-
but since this reference points to ITSELF, it doesn't do that.
3+
$ref: "definitions/thing.yaml"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
helper.bundled.circularExtended =
2+
{
3+
"self": {
4+
"definitions": {
5+
"thing": {
6+
"title": "thing",
7+
"$ref": "#/definitions/thing",
8+
"description": "This JSON Reference has additional properties (other than $ref). Normally, this creates a new type that extends the referenced type, but since this reference points to ITSELF, it doesn't do that.\n",
9+
}
10+
}
11+
},
12+
13+
pet: {
14+
"title": "pet",
15+
"type": "object",
16+
"properties": {
17+
"age": {
18+
type: "number"
19+
},
20+
"name": {
21+
type: "string"
22+
},
23+
"species": {
24+
"type": "string",
25+
"enum": [
26+
"cat",
27+
"dog",
28+
"bird",
29+
"fish"
30+
],
31+
},
32+
},
33+
},
34+
35+
ancestor: {
36+
"definitions": {
37+
"person": {
38+
"title": "person",
39+
"properties": {
40+
"spouse": {
41+
"$ref": "#/definitions/person",
42+
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"person\".\n",
43+
},
44+
"pet": {
45+
$ref: "#/definitions/pet",
46+
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"pet\".\n"
47+
},
48+
"name": {
49+
"type": "string"
50+
}
51+
}
52+
},
53+
"pet": null
54+
}
55+
},
56+
57+
indirect: {
58+
"definitions": {
59+
"parent": {
60+
"title": "parent",
61+
"properties": {
62+
"name": {
63+
"type": "string"
64+
},
65+
"children": {
66+
"items": {
67+
"$ref": "#/definitions/child",
68+
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"child\".\n",
69+
},
70+
"type": "array"
71+
}
72+
}
73+
},
74+
"child": {
75+
"title": "child",
76+
"properties": {
77+
"parents": {
78+
"items": {
79+
"$ref": "#/definitions/parent",
80+
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"parent\".\n",
81+
},
82+
"type": "array"
83+
},
84+
"pet": {
85+
"$ref": "#/definitions/pet",
86+
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"pet\".\n",
87+
},
88+
"name": {
89+
"type": "string"
90+
}
91+
}
92+
},
93+
"pet": null
94+
}
95+
},
96+
97+
indirectAncestor: {
98+
"definitions": {
99+
"pet": null,
100+
"parent": {
101+
"title": "parent",
102+
"properties": {
103+
"name": {
104+
"type": "string"
105+
},
106+
"child": {
107+
"$ref": "#/definitions/child",
108+
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"child\".\n",
109+
}
110+
},
111+
},
112+
"child": {
113+
"title": "child",
114+
"properties": {
115+
"pet": {
116+
"$ref": "#/definitions/pet",
117+
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"pet\".\n",
118+
},
119+
"name": {
120+
"type": "string"
121+
},
122+
"children": {
123+
"items": {
124+
"$ref": "#/definitions/child",
125+
"description": "This JSON Reference has additional properties (other than $ref). This creates a new type that extends \"child\".\n",
126+
},
127+
"type": "array",
128+
"description": "children"
129+
}
130+
},
131+
}
132+
}
133+
}
134+
};
135+
136+
helper.bundled.circularExtended.ancestor.definitions.pet =
137+
helper.bundled.circularExtended.indirect.definitions.pet =
138+
helper.bundled.circularExtended.indirectAncestor.definitions.pet =
139+
helper.bundled.circularExtended.pet;

0 commit comments

Comments
 (0)