Skip to content

Commit caa4ef7

Browse files
authored
Update Convertor.spec.js
1 parent 3324952 commit caa4ef7

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
@@ -18,6 +18,7 @@ const moreComplexOneOfSchema = require('../schemas/morecomplex-oneOf')
1818
const complexPropertySchema = require('../schemas/complex-property')
1919
const complexPropertyDefinitionSchema = require('../schemas/complex-propertyDefinition')
2020
const complexResolvedDefinitionSchema = require('../schemas/complex-resolvedDefinition')
21+
const complexNullTypeSchema = require('../schemas/complex-null')
2122

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

@@ -36,6 +37,7 @@ describe('Convertor', () => {
3637
delete require.cache[require.resolve('../schemas/complex-property')];
3738
delete require.cache[require.resolve('../schemas/complex-propertyDefinition')];
3839
delete require.cache[require.resolve('../schemas/complex-resolvedDefinition')];
40+
delete require.cache[require.resolve('../schemas/complex-null')];
3941
convertor = new Convertor(simpleSchema)
4042
});
4143

@@ -369,4 +371,24 @@ describe('Convertor', () => {
369371
expect(valid).to.be.true
370372
});
371373
});
374+
375+
describe('convert a schema with null types', () => {
376+
it('should return a schema valid for OpenAPI v3.0.0', async function() {
377+
const complexConvertor = new Convertor(complexNullTypeSchema)
378+
const components = complexConvertor.convert()
379+
const cloned = JSON.parse(JSON.stringify(simpleOpenAPI))
380+
let valid = await validator.validateInner(cloned, {})
381+
expect(valid).to.be.true
382+
Object.assign(cloned, {components})
383+
expect(cloned).to.have.property('components')
384+
expect(cloned.components).to.have.property('schemas')
385+
expect(cloned.components.schemas).to.have.property('main')
386+
expect(cloned.components.schemas.main).to.not.have.property('definitions')
387+
valid = await validator.validateInner(cloned, {})
388+
.catch(err => {
389+
console.log(err)
390+
})
391+
expect(valid).to.be.true
392+
});
393+
});
372394
});

0 commit comments

Comments
 (0)