@@ -236,4 +236,180 @@ describe('createResolvedObject', () => {
236
236
237
237
expect ( resolvedObject ) . toEqual ( originalObject ) ;
238
238
} ) ;
239
+
240
+ // If the schema is internal, the object contains 'x-sl-error-message' on logout.
241
+ it ( 'removes object if contains an error for oneOf' , ( ) => {
242
+ const originalObject = {
243
+ oneOf : [
244
+ { $ref : '#/__bundled__/0mui9s02880hl' , 'x-stoplight' : { id : '19c178fc05d4a' } } ,
245
+ {
246
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
247
+ 'x-stoplight' : { 'error-message' : 'You do not have permission to view this reference' , id : 'nezai0hyj4yak' } ,
248
+ } ,
249
+ { $ref : '#/__bundled__/iq2mwk8jvthd2' , 'x-stoplight' : { id : 'ovj32wmpxpg7p' } } ,
250
+ ] ,
251
+ 'x-stoplight' : { id : 'b73ff5df9864f' } ,
252
+ } ;
253
+
254
+ const filteredObject = {
255
+ oneOf : [
256
+ { $ref : '#/__bundled__/0mui9s02880hl' , 'x-stoplight' : { id : '19c178fc05d4a' } } ,
257
+ { $ref : '#/__bundled__/iq2mwk8jvthd2' , 'x-stoplight' : { id : 'ovj32wmpxpg7p' } } ,
258
+ ] ,
259
+ 'x-stoplight' : { id : 'b73ff5df9864f' } ,
260
+ } ;
261
+ const resolvedObject = getOriginalObject ( originalObject ) ;
262
+
263
+ expect ( resolvedObject ) . toEqual ( filteredObject ) ;
264
+ } ) ;
265
+
266
+ it ( 'removes object if contains an error for anyeOf' , ( ) => {
267
+ const originalObject = {
268
+ anyOf : [
269
+ { $ref : '#/__bundled__/0mui9s02880hl' , 'x-stoplight' : { id : '19c178fc05d4a' } } ,
270
+ {
271
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
272
+ 'x-stoplight' : { 'error-message' : 'You do not have permission to view this reference' , id : 'nezai0hyj4yak' } ,
273
+ } ,
274
+ { $ref : '#/__bundled__/iq2mwk8jvthd2' , 'x-stoplight' : { id : 'ovj32wmpxpg7p' } } ,
275
+ ] ,
276
+ 'x-stoplight' : { id : 'b73ff5df9864f' } ,
277
+ } ;
278
+
279
+ const filteredObject = {
280
+ anyOf : [
281
+ { $ref : '#/__bundled__/0mui9s02880hl' , 'x-stoplight' : { id : '19c178fc05d4a' } } ,
282
+ { $ref : '#/__bundled__/iq2mwk8jvthd2' , 'x-stoplight' : { id : 'ovj32wmpxpg7p' } } ,
283
+ ] ,
284
+ 'x-stoplight' : { id : 'b73ff5df9864f' } ,
285
+ } ;
286
+ const resolvedObject = getOriginalObject ( originalObject ) ;
287
+
288
+ expect ( resolvedObject ) . toEqual ( filteredObject ) ;
289
+ } ) ;
290
+
291
+ it ( 'show the error if all schemas are internal for anyOf' , ( ) => {
292
+ const originalObject = {
293
+ anyOf : [
294
+ [
295
+ {
296
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
297
+ 'x-stoplight' : {
298
+ 'error-message' : 'You do not have permission to view this reference' ,
299
+ id : 'nezai0hyj4yak' ,
300
+ } ,
301
+ } ,
302
+ {
303
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
304
+ 'x-stoplight' : {
305
+ 'error-message' : 'You do not have permission to view this reference' ,
306
+ id : 'nezai0hyj4yak' ,
307
+ } ,
308
+ } ,
309
+ {
310
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
311
+ 'x-stoplight' : {
312
+ 'error-message' : 'You do not have permission to view this reference' ,
313
+ id : 'nezai0hyj4yak' ,
314
+ } ,
315
+ } ,
316
+ ] ,
317
+ ] ,
318
+ 'x-stoplight' : { id : 'b73ff5df9864f' } ,
319
+ } ;
320
+
321
+ const filteredObject = {
322
+ anyOf : [
323
+ [
324
+ {
325
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
326
+ 'x-stoplight' : {
327
+ 'error-message' : 'You do not have permission to view this reference' ,
328
+ id : 'nezai0hyj4yak' ,
329
+ } ,
330
+ } ,
331
+ {
332
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
333
+ 'x-stoplight' : {
334
+ 'error-message' : 'You do not have permission to view this reference' ,
335
+ id : 'nezai0hyj4yak' ,
336
+ } ,
337
+ } ,
338
+ {
339
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
340
+ 'x-stoplight' : {
341
+ 'error-message' : 'You do not have permission to view this reference' ,
342
+ id : 'nezai0hyj4yak' ,
343
+ } ,
344
+ } ,
345
+ ] ,
346
+ ] ,
347
+ 'x-stoplight' : { id : 'b73ff5df9864f' } ,
348
+ } ;
349
+ const resolvedObject = getOriginalObject ( originalObject ) ;
350
+
351
+ expect ( resolvedObject ) . toEqual ( filteredObject ) ;
352
+ } ) ;
353
+ it ( 'show the error if all schemas are internal for oneOf' , ( ) => {
354
+ const originalObject = {
355
+ oneOf : [
356
+ [
357
+ {
358
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
359
+ 'x-stoplight' : {
360
+ 'error-message' : 'You do not have permission to view this reference' ,
361
+ id : 'nezai0hyj4yak' ,
362
+ } ,
363
+ } ,
364
+ {
365
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
366
+ 'x-stoplight' : {
367
+ 'error-message' : 'You do not have permission to view this reference' ,
368
+ id : 'nezai0hyj4yak' ,
369
+ } ,
370
+ } ,
371
+ {
372
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
373
+ 'x-stoplight' : {
374
+ 'error-message' : 'You do not have permission to view this reference' ,
375
+ id : 'nezai0hyj4yak' ,
376
+ } ,
377
+ } ,
378
+ ] ,
379
+ ] ,
380
+ 'x-stoplight' : { id : 'b73ff5df9864f' } ,
381
+ } ;
382
+
383
+ const filteredObject = {
384
+ oneOf : [
385
+ [
386
+ {
387
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
388
+ 'x-stoplight' : {
389
+ 'error-message' : 'You do not have permission to view this reference' ,
390
+ id : 'nezai0hyj4yak' ,
391
+ } ,
392
+ } ,
393
+ {
394
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
395
+ 'x-stoplight' : {
396
+ 'error-message' : 'You do not have permission to view this reference' ,
397
+ id : 'nezai0hyj4yak' ,
398
+ } ,
399
+ } ,
400
+ {
401
+ 'x-sl-error-message' : 'You do not have permission to view this reference' ,
402
+ 'x-stoplight' : {
403
+ 'error-message' : 'You do not have permission to view this reference' ,
404
+ id : 'nezai0hyj4yak' ,
405
+ } ,
406
+ } ,
407
+ ] ,
408
+ ] ,
409
+ 'x-stoplight' : { id : 'b73ff5df9864f' } ,
410
+ } ;
411
+ const resolvedObject = getOriginalObject ( originalObject ) ;
412
+
413
+ expect ( resolvedObject ) . toEqual ( filteredObject ) ;
414
+ } ) ;
239
415
} ) ;
0 commit comments