Skip to content

Commit 665f22e

Browse files
committed
add a test for items being an array
1 parent b380b12 commit 665f22e

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
@@ -23,6 +23,7 @@ const complexNullTypeSchema = require('../schemas/complex-null')
2323
const complexTypeArraySchema = require('../schemas/complex-typeArray')
2424
const complexDefaultValuesSchema = require('../schemas/complex-defaultValues')
2525
const complexAdditionalPropertiesSchema = require('../schemas/complex-additionalProperties')
26+
const complexItemsAsArraySchema = require('../schemas/complex-itemsAsArray')
2627

2728
const 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

Comments
 (0)