You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fixesgo-openapi#94
* now expanded $ref are always contained in the resulting document.
All circular $ref that used to resolve to a remote $ref now resolve
as a json pointer inside the expanded document.
* schema IDs are removed from the expanded spec: schemas expanded from some schema ID reference
now refer to the new expanded root document.
* fixed circular ID resolution
Signed-off-by: Frederic BIDON <[email protected]>
// cannot guarantee that the circular will always hook on the same $ref
203
+
// but we can assert that thre is only one
204
+
m:=rex.FindAllStringSubmatch(jazon, -1)
205
+
require.NotEmpty(t, m)
190
206
191
-
// cannot guarantee that the circular will always hook on the same $ref
192
-
// but we can assert that there is only one
193
-
m:=rex.FindAllStringSubmatch(jazon, -1)
194
-
require.NotEmpty(t, m)
207
+
refs:=make(map[string]struct{}, 5)
208
+
for_, matched:=rangem {
209
+
subMatch:=matched[1]
210
+
refs[subMatch] =struct{}{}
211
+
}
212
+
213
+
// TODO(fred): the expansion is incorrect (it was already, with an undetected empty $ref)
214
+
// require.Len(t, refs, 1)
215
+
require.Len(t, refs, 1)
216
+
})
217
+
}
195
218
196
-
refs:=make(map[string]struct{}, 5)
197
-
for_, matched:=rangem {
198
-
subMatch:=matched[1]
199
-
refs[subMatch] =struct{}{}
219
+
funcTestSortRefTracker(t*testing.T) {
220
+
tracked:=refTrackers{
221
+
refTracker{Pointer: "/c/d/e"},
222
+
refTracker{Pointer: "/definitions/x"},
223
+
refTracker{Pointer: "/a/b/c/d"},
224
+
refTracker{Pointer: "/b"},
225
+
refTracker{Pointer: "/z"},
226
+
refTracker{Pointer: "/definitions/a"},
200
227
}
228
+
sort.Sort(tracked)
229
+
require.EqualValues(t, refTrackers{
230
+
refTracker{Pointer: "/definitions/a"},
231
+
refTracker{Pointer: "/definitions/x"},
232
+
refTracker{Pointer: "/b"},
233
+
refTracker{Pointer: "/z"},
234
+
refTracker{Pointer: "/c/d/e"},
235
+
refTracker{Pointer: "/a/b/c/d"},
236
+
}, tracked)
237
+
}
238
+
239
+
funcTestRemoteExpandAzure(t*testing.T) {
240
+
// local copy of : https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2020-04-01/publicIpAddress.json
0 commit comments