Fix object to become an array (#146)

This commit is contained in:
Roman Hotsiy 2016-11-28 20:03:01 +02:00
parent 19bc9227f4
commit c281c62b36
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
3 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, 'array': schema._isArray}"
[ngClass]="{'with-hint': schema._displayTypeHint, 'array': _isArray}"
title="{{schema._displayTypeHint}}">{{schema._displayType}} {{schema._displayFormat}}
<span class="param-range" *ngIf="schema._range"> {{schema._range}} </span>
</span>
@ -45,7 +45,7 @@
[nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema"> </json-schema>
</template>
<template ngSwitchCase="object">
<table class="params-wrap" [ngClass]="{'params-array': schema._isArray}">
<table class="params-wrap" [ngClass]="{'params-array': _isArray}">
<!-- <caption> {{_displayType}} </caption> -->
<template ngFor [ngForOf]="properties" let-prop="$implicit" let-last="last" [ngForTrackBy]="trackByName">
<tr class="param" [ngClass]="{'last': last,

View File

@ -84,6 +84,7 @@ export class JsonSchema extends BaseComponent implements OnInit {
this.schema = this.normalizer.normalize(this.schema, this.normPointer, {resolved: true});
this.schema = SchemaHelper.unwrapArray(this.schema, this.normPointer);
this._isArray = this.schema._isArray;
this.initDescendants();
this.preprocessSchema();
}

View File

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