1- import { cloneDeep , get } from 'lodash' ;
1+ import { cloneDeep } from 'lodash' ;
22
33import { BUNDLE_ROOT , bundleTarget } from '../bundle' ;
4- import { pointerToPath } from '../pointerToPath' ;
54import { safeStringify } from '../safeStringify' ;
65
76describe ( 'bundleTargetPath()' , ( ) => {
@@ -360,7 +359,7 @@ describe('bundleTargetPath()', () => {
360359 } ,
361360 [ BUNDLE_ROOT ] : {
362361 parameters : [
363- undefined ,
362+ null ,
364363 {
365364 schema : {
366365 name : 'param' ,
@@ -562,6 +561,17 @@ describe('bundleTargetPath()', () => {
562561 const document = {
563562 components : {
564563 schemas : {
564+ bar : {
565+ type : 'array' ,
566+ items : [
567+ {
568+ type : 'string' ,
569+ } ,
570+ {
571+ type : 'number' ,
572+ } ,
573+ ] ,
574+ } ,
565575 foo : {
566576 allOf : [
567577 { } ,
@@ -575,37 +585,70 @@ describe('bundleTargetPath()', () => {
575585 } ,
576586 ] ,
577587 } ,
578- foo_again : {
579- allOf : [
580- {
581- $ref : '#/components/schemas/foo/allOf/0' ,
582- } ,
583- {
584- type : 'object' ,
585- properties : {
586- attributes : {
587- allOf : [
588- { } ,
589- {
590- $ref : '#/components/schemas/foo/allOf/1/properties/attributes/allOf/1' ,
591- } ,
592- ] ,
588+ baz : {
589+ type : 'object' ,
590+ properties : {
591+ attributes : {
592+ anyOf : [
593+ {
594+ $ref : '#/components/schemas/bar/items/1' ,
593595 } ,
594- } ,
596+ {
597+ $ref : '#/components/schemas/foo/allOf/1/properties/attributes/allOf/1' ,
598+ } ,
599+ ] ,
595600 } ,
596- ] ,
601+ } ,
597602 } ,
598603 } ,
599604 } ,
600605 } ;
601606
602607 const result = bundleTarget ( {
603608 document,
604- path : '#/components/schemas/foo_again ' ,
609+ path : '#/components/schemas/baz ' ,
605610 } ) ;
606611
607- expect (
608- '0' in get ( result , pointerToPath ( '#/__bundled__/components/schemas/foo/allOf/1/properties/attributes/allOf' ) ) ,
609- ) . toBe ( true ) ;
612+ expect ( result ) . toStrictEqual ( {
613+ type : 'object' ,
614+ properties : {
615+ attributes : {
616+ anyOf : [
617+ {
618+ $ref : '#/__bundled__/components/schemas/bar/items/1' ,
619+ } ,
620+ {
621+ $ref : '#/__bundled__/components/schemas/foo/allOf/1/properties/attributes/allOf/1' ,
622+ } ,
623+ ] ,
624+ } ,
625+ } ,
626+ __bundled__ : {
627+ components : {
628+ schemas : {
629+ bar : {
630+ items : [
631+ null ,
632+ {
633+ type : 'number' ,
634+ } ,
635+ ] ,
636+ } ,
637+ foo : {
638+ allOf : [
639+ null ,
640+ {
641+ properties : {
642+ attributes : {
643+ allOf : [ null , { } ] ,
644+ } ,
645+ } ,
646+ } ,
647+ ] ,
648+ } ,
649+ } ,
650+ } ,
651+ } ,
652+ } ) ;
610653 } ) ;
611654} ) ;
0 commit comments