From fc86c93d878e5440db2de6e7757badd3e4cf6f27 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 13 Apr 2016 14:21:56 +0300 Subject: [PATCH] Fix discriminator end-less recursion --- lib/components/JsonSchema/json-schema.html | 2 +- lib/components/JsonSchema/json-schema.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index d1377c59..cab1de2c 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -47,7 +47,7 @@
- +
diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 4434b935..552264e3 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -11,7 +11,7 @@ import JsonPointer from '../../utils/JsonPointer'; templateUrl: './lib/components/JsonSchema/json-schema.html', styleUrls: ['./lib/components/JsonSchema/json-schema.css'], directives: [JsonSchema, Tabs, Tab], - inputs: ['isArray', 'final', 'nestOdd'] + inputs: ['isArray', 'final', 'nestOdd', 'childFor'] }) @Reflect.metadata('parameters', [[SchemaManager], [ElementRef]]) export default class JsonSchema extends BaseComponent { @@ -74,6 +74,10 @@ export default class JsonSchema extends BaseComponent { let propertySchema = schema.properties[prop]; let propPointer = JsonPointer.join(schema._pointer || this.pointer, ['properties', prop]); propertySchema = JsonSchema.injectPropertyData(propertySchema, prop, propPointer); + // stop endless discriminator recursion + if (propertySchema._pointer === this.childFor) { + propertySchema._pointer = null; + } propertySchema.required = !!requiredMap[prop]; propertySchema.isDiscriminator = (schema.discriminator === prop); if (propertySchema.isDiscriminator) discriminatorFieldIdx = idx;