Skip to content

Commit bc6d4a3

Browse files
committed
update tests for $comment and resolved definitions
1 parent 15168f8 commit bc6d4a3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/src/Convertor.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const complexOneOfSchema = require('../schemas/complex-oneOf')
1717
const moreComplexOneOfSchema = require('../schemas/morecomplex-oneOf')
1818
const complexPropertySchema = require('../schemas/complex-property')
1919
const complexPropertyDefinitionSchema = require('../schemas/complex-propertyDefinition')
20+
const complexResolvedDefinitionSchema = require('../schemas/complex-resolvedDefinition')
2021

2122
const simpleOpenAPI = require('../openAPI/simple')
2223

@@ -34,6 +35,7 @@ describe('Convertor', () => {
3435
delete require.cache[require.resolve('../schemas/morecomplex-oneOf')];
3536
delete require.cache[require.resolve('../schemas/complex-property')];
3637
delete require.cache[require.resolve('../schemas/complex-propertyDefinition')];
38+
delete require.cache[require.resolve('../schemas/complex-resolvedDefinition')];
3739
convertor = new Convertor(simpleSchema)
3840
});
3941

@@ -347,4 +349,24 @@ describe('Convertor', () => {
347349
expect(valid).to.be.true
348350
});
349351
});
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+
});
350372
});

0 commit comments

Comments
 (0)