Skip to content

Commit 22721a0

Browse files
authored
Implicit any type for array items (#234)
1 parent d81c64f commit 22721a0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,11 @@ function buildArray (schema, code, name, externalSchema, fullSchema) {
909909
`
910910
var laterCode = ''
911911

912+
// default to any items type
913+
if (!schema.items) {
914+
schema.items = {}
915+
}
916+
912917
if (schema.items.$ref) {
913918
schema.items = refFinder(schema.items.$ref, fullSchema, externalSchema)
914919
}

test/array.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,15 @@ test('moment array', (t) => {
201201
t.fail(e)
202202
}
203203
})
204+
205+
buildTest({
206+
title: 'item types in array default to any',
207+
type: 'object',
208+
properties: {
209+
foo: {
210+
type: 'array'
211+
}
212+
}
213+
}, {
214+
foo: [1, 'string', {}, null]
215+
})

0 commit comments

Comments
 (0)