@@ -17,6 +17,7 @@ const complexOneOfSchema = require('../schemas/complex-oneOf')
17
17
const moreComplexOneOfSchema = require ( '../schemas/morecomplex-oneOf' )
18
18
const complexPropertySchema = require ( '../schemas/complex-property' )
19
19
const complexPropertyDefinitionSchema = require ( '../schemas/complex-propertyDefinition' )
20
+ const complexResolvedDefinitionSchema = require ( '../schemas/complex-resolvedDefinition' )
20
21
21
22
const simpleOpenAPI = require ( '../openAPI/simple' )
22
23
@@ -34,6 +35,7 @@ describe('Convertor', () => {
34
35
delete require . cache [ require . resolve ( '../schemas/morecomplex-oneOf' ) ] ;
35
36
delete require . cache [ require . resolve ( '../schemas/complex-property' ) ] ;
36
37
delete require . cache [ require . resolve ( '../schemas/complex-propertyDefinition' ) ] ;
38
+ delete require . cache [ require . resolve ( '../schemas/complex-resolvedDefinition' ) ] ;
37
39
convertor = new Convertor ( simpleSchema )
38
40
} ) ;
39
41
@@ -347,4 +349,24 @@ describe('Convertor', () => {
347
349
expect ( valid ) . to . be . true
348
350
} ) ;
349
351
} ) ;
352
+
353
+ describe ( 'convert a schema that has definitions that have already been resolved' , ( ) => {
354
+ it ( 'should return a schema valid for OpenAPI v3.0.0' , async function ( ) {
355
+ const complexConvertor = new Convertor ( complexResolvedDefinitionSchema )
356
+ const components = complexConvertor . convert ( )
357
+ const cloned = JSON . parse ( JSON . stringify ( simpleOpenAPI ) )
358
+ let valid = await validator . validateInner ( cloned , { } )
359
+ expect ( valid ) . to . be . true
360
+ Object . assign ( cloned , { components} )
361
+ expect ( cloned ) . to . have . property ( 'components' )
362
+ expect ( cloned . components ) . to . have . property ( 'schemas' )
363
+ expect ( cloned . components . schemas ) . to . have . property ( 'main' )
364
+ expect ( cloned . components . schemas . main ) . to . not . have . property ( 'definitions' )
365
+ valid = await validator . validateInner ( cloned , { } )
366
+ . catch ( err => {
367
+ console . log ( err )
368
+ } )
369
+ expect ( valid ) . to . be . true
370
+ } ) ;
371
+ } ) ;
350
372
} ) ;
0 commit comments