Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 142ca43

Browse files
author
Phil Sturgeon
authored
Merge pull request #17 from MikeRalphson/arrayItems
items must always be present for type:array
2 parents 17e4ffc + 35c4e77 commit 142ca43

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

‎index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ function convertSchema(schema, path, parent, parentPath) {
3535
schema = convertPatternProperties(schema);
3636
}
3737

38+
if (schema.type === 'array' && typeof schema.items === 'undefined') {
39+
schema.items = {};
40+
}
41+
3842
return schema;
3943
}
4044

‎test/array-items.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
const convert = require('../');
4+
const should = require('should');
5+
6+
it('array-items', () => {
7+
const schema = {
8+
$schema: 'http://json-schema.org/draft-04/schema#',
9+
type: 'array',
10+
};
11+
12+
const result = convert(schema);
13+
14+
const expected = {
15+
type: 'array',
16+
items: {
17+
}
18+
};
19+
20+
should(result).deepEqual(expected, 'converted');
21+
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /