Skip to content

Commit

Permalink
Fix object to become an array (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Nov 28, 2016
1 parent 19bc922 commit c281c62
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions 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, '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>
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lib/components/JsonSchema/json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/services/schema-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c281c62

Please sign in to comment.