From afd42a955a27c95a9d88286a7c09a3b308b8ac21 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sun, 18 Oct 2015 12:28:48 +0300 Subject: [PATCH] Add missing title injecting to Schema --- lib/components/JsonSchemaView/json-schema-view.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/components/JsonSchemaView/json-schema-view.js b/lib/components/JsonSchemaView/json-schema-view.js index 47f46326..a75cdf68 100644 --- a/lib/components/JsonSchemaView/json-schema-view.js +++ b/lib/components/JsonSchemaView/json-schema-view.js @@ -9,11 +9,11 @@ import JSONSchemaView from 'json-schema-view-js/src/index'; import 'json-schema-view-js/dist/style.css!'; import {ElementRef} from 'angular2/angular2'; +import {JsonPointer} from '../../utils/JsonPointer'; @RedocComponent({ selector: 'schema', - template: '', - inputs: ['title', 'description'] + template: '' }) export class JsonSchemaView extends BaseComponent { constructor(schemaMgr, elementRef) { @@ -27,8 +27,11 @@ export class JsonSchemaView extends BaseComponent { // TODO: doesn't support circular references if (schema && schema.$ref) { let resolved = this.schemaMgr.byPointer(schema.$ref); + let baseName = JsonPointer.baseName(schema.$ref); + // if resolved schema doesn't have title use name from ref + resolved.title = resolved.title || baseName; Object.assign(schema, resolved); - delete schema.$ref; + schema.$ref = null; } Object.keys(schema).forEach((key) => { @@ -41,8 +44,6 @@ export class JsonSchemaView extends BaseComponent { init() { this.dereference(); - this.componentSchema.title = this.componentSchema.title || this.title; - this.componentSchema.description = this.componentSchema.description || this.description; const formatter = new JSONSchemaView(this.componentSchema, 1); this.element.appendChild(formatter.render()); }