@@ -28,6 +28,7 @@ const defaultNumbers = require('../schemas/defaultValues/defaultNumbers.json')
28
28
const defaultString = require ( '../schemas/defaultValues/defaultString.json' )
29
29
// array items
30
30
const basicArray = require ( '../schemas/arrayItems/basicArray.json' )
31
+ const multiArray = require ( '../schemas/arrayItems/multipleItemArray.json' )
31
32
// const values
32
33
const basicConst = require ( '../schemas/const/basicConst.json' )
33
34
// if/then/else schemas
@@ -331,6 +332,24 @@ describe('Convertor', () => {
331
332
let valid = await validator . validateInner ( cloned , { } )
332
333
expect ( valid ) . to . be . true
333
334
} ) ;
335
+
336
+ it ( 'should only use the first item in the array and discard the others' , async function ( ) {
337
+ const newConvertor = new Convertor ( multiArray )
338
+ const result = newConvertor . convert ( 'basic' )
339
+ expect ( result . schemas . basic . properties . names ) . to . have . property ( 'type' )
340
+ expect ( result . schemas . basic . properties . names . type ) . to . be . equal ( 'array' )
341
+ expect ( result . schemas . basic . properties . names . items ) . to . be . an ( 'object' )
342
+ expect ( result . schemas . basic . properties . names . items ) . to . not . be . an ( 'array' )
343
+ expect ( result . schemas . basic . properties . names . items . type ) . to . equal ( 'object' )
344
+
345
+ const cloned = JSON . parse ( JSON . stringify ( basicOpenAPI ) )
346
+ Object . assign ( cloned , { components : result } )
347
+ expect ( cloned ) . to . have . property ( 'components' )
348
+ expect ( cloned . components ) . to . have . property ( 'schemas' )
349
+ expect ( cloned . components . schemas ) . to . have . property ( 'basic' )
350
+ let valid = await validator . validateInner ( cloned , { } )
351
+ expect ( valid ) . to . be . true
352
+ } ) ;
334
353
} ) ;
335
354
336
355
describe ( 'const values' , ( ) => {
0 commit comments