@@ -28,6 +28,7 @@ const defaultNumbers = require('../schemas/defaultValues/defaultNumbers.json')
2828const defaultString = require ( '../schemas/defaultValues/defaultString.json' )
2929// array items
3030const basicArray = require ( '../schemas/arrayItems/basicArray.json' )
31+ const multiArray = require ( '../schemas/arrayItems/multipleItemArray.json' )
3132// const values
3233const basicConst = require ( '../schemas/const/basicConst.json' )
3334// if/then/else schemas
@@ -331,6 +332,24 @@ describe('Convertor', () => {
331332 let valid = await validator . validateInner ( cloned , { } )
332333 expect ( valid ) . to . be . true
333334 } ) ;
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+ } ) ;
334353 } ) ;
335354
336355 describe ( 'const values' , ( ) => {
0 commit comments