Skip to content

Commit c55c19f

Browse files
authored
Handle items: [{ $ref }]
Signed-off-by: rtkevin <[email protected]>
1 parent 6c2a4a7 commit c55c19f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,14 @@ function buildArray (context, location) {
564564

565565
if (Array.isArray(itemsSchema)) {
566566
for (let i = 0; i < itemsSchema.length; i++) {
567-
const item = itemsSchema[i]
567+
let item = itemsSchema[i]
568+
let itemLocation = itemsLocation.getPropertyLocation(i)
569+
if (item.$ref) {
570+
itemLocation = resolveRef(context, itemLocation)
571+
item = itemLocation.schema
572+
}
568573
functionCode += `value = obj[${i}]`
569-
const tmpRes = buildValue(context, itemsLocation.getPropertyLocation(i), 'value')
574+
const tmpRes = buildValue(context, itemLocation, 'value')
570575
functionCode += `
571576
if (${i} < arrayLength) {
572577
if (${buildArrayTypeCondition(item.type, `[${i}]`)}) {

0 commit comments

Comments
 (0)