@@ -23,6 +23,7 @@ const complexNullTypeSchema = require('../schemas/complex-null')
2323const complexTypeArraySchema = require ( '../schemas/complex-typeArray' )
2424const complexDefaultValuesSchema = require ( '../schemas/complex-defaultValues' )
2525const complexAdditionalPropertiesSchema = require ( '../schemas/complex-additionalProperties' )
26+ const complexItemsAsArraySchema = require ( '../schemas/complex-itemsAsArray' )
2627
2728const simpleOpenAPI = require ( '../openAPI/simple' )
2829
@@ -464,6 +465,27 @@ describe('Convertor', () => {
464465 } ) ;
465466 } ) ;
466467
468+ describe ( 'convert a schema with items as an array' , ( ) => {
469+ it ( 'should return a schema valid for OpenAPI v3.0.0' , async function ( ) {
470+ const complexConvertor = new Convertor ( complexItemsAsArraySchema )
471+ const components = complexConvertor . convert ( )
472+
473+ const cloned = JSON . parse ( JSON . stringify ( simpleOpenAPI ) )
474+ let valid = await validator . validateInner ( cloned , { } )
475+ expect ( valid ) . to . be . true
476+ Object . assign ( cloned , { components} )
477+ expect ( cloned ) . to . have . property ( 'components' )
478+ expect ( cloned . components ) . to . have . property ( 'schemas' )
479+ expect ( cloned . components . schemas ) . to . have . property ( 'main' )
480+ expect ( cloned . components . schemas . main ) . to . not . have . property ( 'definitions' )
481+ valid = await validator . validateInner ( cloned , { } )
482+ . catch ( err => {
483+ console . log ( err )
484+ } )
485+ expect ( valid ) . to . be . true
486+ } ) ;
487+ } ) ;
488+
467489 describe ( 'use a repo with lots of schemas to find failing ones' , ( ) => {
468490 xit ( 'should convert all schemas successfully' , async function ( ) {
469491 this . timeout ( 5000 ) ;
0 commit comments