diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js
index 6db70904..cd6ccdad 100644
--- a/lib/components/JsonSchema/json-schema.js
+++ b/lib/components/JsonSchema/json-schema.js
@@ -7,7 +7,8 @@ import {ElementRef} from 'angular2/angular2';
selector: 'json-schema',
templateUrl: './lib/components/JsonSchema/json-schema.html',
styleUrls: ['./lib/components/JsonSchema/json-schema.css'],
- directives: [JsonSchema]
+ directives: [JsonSchema],
+ inputs: ['isArray']
})
export default class JsonSchema extends BaseComponent {
constructor(schemaMgr, elementRef) {
@@ -16,31 +17,38 @@ export default class JsonSchema extends BaseComponent {
}
prepareModel() {
+ this.data = {};
+ this.data.properties = [];
+
+ if (!this.componentSchema) {
+ // TODO
+ this.errorMessage = 'Can\'t load component schema';
+ console.warn(`${this.errorMessage}: ${this.pointer}`);
+ return;
+ }
+
this.dereference();
- this.joinAllOf();
+ let schema = this.componentSchema;
+
+ if (schema.type === 'array') {
+ this.isArray = true;
+ schema = schema.items;
+ }
+ this.joinAllOf(schema);
+
+ if (schema.type !== 'object') {
+ // TODO
+ this.errorMessage = 'Non-object and non-array schemas are not implemented yet';
+ console.warn(`${this.errorMessage}: ${schema.type}`);
+ return;
+ }
+
+ this.pointer = schema._pointer || this.pointer;
+
this.requiredMap = {};
if (this.schema.required) {
this.schema.required.forEach(prop => this.requiredMap[prop] = true);
}
- let schema = this.componentSchema;
- this.data = {};
- this.data.properties = [];
- if (schema.type !== 'object' && schema.type !== 'array') {
- // TODO
- this.errorMessage = 'Non-object and non-array schemas are not implemented yet';
- return;
- }
-
- if (schema.type === 'array') {
- this._isArray = true;
- this.pointer = schema.items._pointer || this.pointer;
- schema = schema.items;
- }
-
- if (schema.type === 'object') {
- this.pointer = schema._pointer || this.pointer;
- }
-
if (!schema.properties) return;
let props = Object.keys(schema.properties).map(prop => {
@@ -70,7 +78,7 @@ export default class JsonSchema extends BaseComponent {
let itemType = propData.items.type;
if (itemType === 'object') {
itemType = propData.items.title || 'object';
- propData._pointer = this.pointer + '/properties/' + prop;
+ propData._pointer = propData.items._pointer || this.pointer + '/properties/' + prop + '/items';
}
propData._displayType= `array of ${itemType}`;
propData._isArray = true;