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()); }