Fix crashing on array without items (fixes #104)

This commit is contained in:
Roman Hotsiy 2016-11-02 13:39:01 +02:00
parent 2ac8b3af3c
commit 0a939d1548
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 4 additions and 3 deletions

View File

@ -17,7 +17,7 @@
<template ngSwitchCase="trivial">
<span class="param-wrap">
<span class="param-type param-type-trivial {{schema.type}}"
[ngClass]="{'with-hint': schema._displayTypeHint}"
[ngClass]="{'with-hint': schema._displayTypeHint, 'array': schema._isArray}"
title="{{schema._displayTypeHint}}">{{schema._displayType}} {{schema._displayFormat}}
<span class="param-range" *ngIf="schema._range"> {{schema._range}} </span>
</span>

View File

@ -262,8 +262,9 @@ export class SchemaHelper {
static unwrapArray(schema, pointer) {
var res = schema;
if (schema && schema.type === 'array' && !Array.isArray(schema.items)) {
let ptr = schema.items._pointer || JsonPointer.join(pointer, ['items']);
res = schema.items;
let items = schema.items = schema.items || {};
let ptr = items._pointer || JsonPointer.join(pointer, ['items']);
res = items;
res._isArray = true;
res._pointer = ptr;
res = SchemaHelper.unwrapArray(res, ptr);