@@ -22,17 +22,20 @@ describe('getSchemaAlternatives', () => {
2222 } ,
2323 ] ,
2424 } )
25- ) . toEqual ( [
26- {
27- type : 'number' ,
28- } ,
29- {
30- type : 'boolean' ,
31- } ,
32- {
33- type : 'string' ,
34- } ,
35- ] ) ;
25+ ) . toEqual ( {
26+ type : 'oneOf' ,
27+ schemas : [
28+ {
29+ type : 'number' ,
30+ } ,
31+ {
32+ type : 'boolean' ,
33+ } ,
34+ {
35+ type : 'string' ,
36+ } ,
37+ ] ,
38+ } ) ;
3639 } ) ;
3740
3841 it ( 'merges string enum' , ( ) => {
@@ -54,13 +57,16 @@ describe('getSchemaAlternatives', () => {
5457 } ,
5558 ] ,
5659 } )
57- ) . toEqual ( [
58- {
59- type : 'string' ,
60- enum : [ 'a' , 'b' , 'c' , 'd' ] ,
61- nullable : true ,
62- } ,
63- ] ) ;
60+ ) . toEqual ( {
61+ type : 'oneOf' ,
62+ schemas : [
63+ {
64+ type : 'string' ,
65+ enum : [ 'a' , 'b' , 'c' , 'd' ] ,
66+ nullable : true ,
67+ } ,
68+ ] ,
69+ } ) ;
6470 } ) ;
6571
6672 it ( 'merges objects with allOf' , ( ) => {
@@ -93,26 +99,29 @@ describe('getSchemaAlternatives', () => {
9399 } ,
94100 ] ,
95101 } )
96- ) . toEqual ( [
97- {
98- type : 'object' ,
99- properties : {
100- name : {
101- type : 'string' ,
102- } ,
103- map : {
104- type : 'string' ,
105- } ,
106- description : {
107- type : 'string' ,
108- } ,
109- externalId : {
110- type : 'string' ,
102+ ) . toEqual ( {
103+ type : 'allOf' ,
104+ schemas : [
105+ {
106+ type : 'object' ,
107+ properties : {
108+ name : {
109+ type : 'string' ,
110+ } ,
111+ map : {
112+ type : 'string' ,
113+ } ,
114+ description : {
115+ type : 'string' ,
116+ } ,
117+ externalId : {
118+ type : 'string' ,
119+ } ,
111120 } ,
121+ required : [ 'name' , 'map' , 'externalId' ] ,
112122 } ,
113- required : [ 'name' , 'map' , 'externalId' ] ,
114- } ,
115- ] ) ;
123+ ] ,
124+ } ) ;
116125 } ) ;
117126
118127 it ( 'should not flatten oneOf and allOf' , ( ) => {
@@ -134,21 +143,24 @@ describe('getSchemaAlternatives', () => {
134143 } ,
135144 ] ,
136145 } )
137- ) . toEqual ( [
138- {
139- allOf : [
140- {
141- type : 'number' ,
142- } ,
143- {
144- type : 'boolean' ,
145- } ,
146- ] ,
147- } ,
148- {
149- type : 'string' ,
150- } ,
151- ] ) ;
146+ ) . toEqual ( {
147+ type : 'oneOf' ,
148+ schemas : [
149+ {
150+ allOf : [
151+ {
152+ type : 'number' ,
153+ } ,
154+ {
155+ type : 'boolean' ,
156+ } ,
157+ ] ,
158+ } ,
159+ {
160+ type : 'string' ,
161+ } ,
162+ ] ,
163+ } ) ;
152164 } ) ;
153165
154166 it ( 'should stop at circular references' , ( ) => {
@@ -162,11 +174,14 @@ describe('getSchemaAlternatives', () => {
162174
163175 a . anyOf ?. push ( a ) ;
164176
165- expect ( getSchemaAlternatives ( a ) ) . toEqual ( [
166- {
167- type : 'string' ,
168- } ,
169- a ,
170- ] ) ;
177+ expect ( getSchemaAlternatives ( a ) ) . toEqual ( {
178+ type : 'anyOf' ,
179+ schemas : [
180+ {
181+ type : 'string' ,
182+ } ,
183+ a ,
184+ ] ,
185+ } ) ;
171186 } ) ;
172187} ) ;
0 commit comments