Skip to content
This repository was archived by the owner on Jul 13, 2023. It is now read-only.

Commit d6d6361

Browse files
authored
fix: deep all of edge case (#64)
1 parent 3f96868 commit d6d6361

File tree

4 files changed

+226
-2
lines changed

4 files changed

+226
-2
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
"swagger": "2.0",
3+
"definitions": {
4+
"Report": {
5+
"type": "object",
6+
"properties": {
7+
"data": {
8+
"$ref": "#/definitions/ReportData"
9+
}
10+
}
11+
},
12+
"ReportData": {
13+
"title": "Report data",
14+
"type": "object",
15+
"properties": {
16+
"device": {
17+
"$ref": "#/definitions/Device"
18+
},
19+
"broadcasts": {
20+
"type": "array",
21+
"items": {
22+
"$ref": "#/definitions/RadioBroadcast"
23+
}
24+
}
25+
}
26+
},
27+
"Device": {
28+
"title": "Device data",
29+
"type": "object",
30+
"properties": {
31+
"make": {
32+
"type": "string"
33+
}
34+
}
35+
},
36+
"RadioBroadcast": {
37+
"allOf": [
38+
{
39+
"$ref": "#/definitions/TimedEvent"
40+
},
41+
{
42+
"type": "object",
43+
"properties": {
44+
"startLoc": {
45+
"$ref": "#/definitions/RadioBroadcastLocation"
46+
},
47+
"stopLoc": {
48+
"$ref": "#/definitions/RadioBroadcastLocation"
49+
}
50+
}
51+
}
52+
]
53+
},
54+
"RadioBroadcastLocation": {
55+
"allOf": [
56+
{
57+
"$ref": "#/definitions/HiResCoordinate"
58+
},
59+
{
60+
"type": "object",
61+
"properties": {
62+
"count": {
63+
"type": "integer"
64+
}
65+
}
66+
}
67+
]
68+
},
69+
"HiResCoordinate": {
70+
"type": "object",
71+
"properties": {
72+
"lat": {
73+
"type": "number"
74+
},
75+
"lng": {
76+
"type": "number"
77+
}
78+
}
79+
},
80+
"TimedEvent": {
81+
"type": "object",
82+
"properties": {
83+
"duration": {
84+
"type": "integer"
85+
},
86+
"startTime": {
87+
"type": "string"
88+
},
89+
"stopTime": {
90+
"type": "string"
91+
}
92+
}
93+
}
94+
}
95+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
{
2+
"input": {
3+
"swagger": "2.0",
4+
"paths": {
5+
"/reports": {
6+
"post": {
7+
"parameters": [
8+
{
9+
"name": "body",
10+
"in": "body",
11+
"required": true,
12+
"schema": {
13+
"$ref": "./deep-all-of-schemas.json#/definitions/Report"
14+
}
15+
}
16+
]
17+
}
18+
}
19+
}
20+
},
21+
"expected": {
22+
"swagger": "2.0",
23+
"paths": {
24+
"/reports": {
25+
"post": {
26+
"parameters": [
27+
{
28+
"name": "body",
29+
"in": "body",
30+
"required": true,
31+
"schema": {
32+
"type": "object",
33+
"properties": {
34+
"data": {
35+
"title": "Report data",
36+
"type": "object",
37+
"properties": {
38+
"device": {
39+
"title": "Device data",
40+
"type": "object",
41+
"properties": {
42+
"make": {
43+
"type": "string"
44+
}
45+
}
46+
},
47+
"broadcasts": {
48+
"type": "array",
49+
"items": {
50+
"allOf": [
51+
{
52+
"type": "object",
53+
"properties": {
54+
"duration": {
55+
"type": "integer"
56+
},
57+
"startTime": {
58+
"type": "string"
59+
},
60+
"stopTime": {
61+
"type": "string"
62+
}
63+
}
64+
},
65+
{
66+
"type": "object",
67+
"properties": {
68+
"startLoc": {
69+
"allOf": [
70+
{
71+
"type": "object",
72+
"properties": {
73+
"lat": {
74+
"type": "number"
75+
},
76+
"lng": {
77+
"type": "number"
78+
}
79+
}
80+
},
81+
{
82+
"type": "object",
83+
"properties": {
84+
"count": {
85+
"type": "integer"
86+
}
87+
}
88+
}
89+
]
90+
},
91+
"stopLoc": {
92+
"allOf": [
93+
{
94+
"type": "object",
95+
"properties": {
96+
"lat": {
97+
"type": "number"
98+
},
99+
"lng": {
100+
"type": "number"
101+
}
102+
}
103+
},
104+
{
105+
"type": "object",
106+
"properties": {
107+
"count": {
108+
"type": "integer"
109+
}
110+
}
111+
}
112+
]
113+
}
114+
}
115+
}
116+
]
117+
}
118+
}
119+
}
120+
}
121+
}
122+
}
123+
}
124+
]
125+
}
126+
}
127+
}
128+
}
129+
}

src/__tests__/resolver.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const runFixtures = (factory: any) => {
3939
const files = fs.readdirSync(dir);
4040

4141
// working on now
42-
// const files: string[] = ['api.links.test.json'];
42+
// const files: string[] = ['deep-all-of.json'];
4343

4444
// the following case (amongst others) does not work in stress test without protective json parse/stringify in resolve
4545
// basicfileref.1.json

src/crawler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export class ResolveCrawler implements Types.ICrawler {
150150

151151
// if we are partially resolving, we need to follow refs (since they might point outside of our initial target object tree)
152152
// only need to initiate when top of pointer stack
153-
if (this.jsonPointer && pointerStack.length === 0) {
153+
if (this.jsonPointer) {
154154
pointerStack.push(targetPointer);
155155

156156
// if we are partially resolving

0 commit comments

Comments
 (0)