Skip to content

Commit

Permalink
Fix crashing on array without items (fixes #104)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Nov 2, 2016
1 parent 2ac8b3a commit 0a939d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/components/JsonSchema/json-schema.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 3 additions & 2 deletions lib/services/schema-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0a939d1

Please sign in to comment.