Fix discriminator end-less recursion

This commit is contained in:
Roman Hotsiy 2016-04-13 14:21:56 +03:00
parent fdb485fa91
commit fc86c93d87
2 changed files with 6 additions and 2 deletions

View File

@ -47,7 +47,7 @@
<tr *ngIf="schema.derived.length" class="param-wrap discriminator-wrap">
<td colspan="2">
<div class="derived-schema" *ngFor="#derived of schema.derived" [ngClass]="{active: derived.active}">
<json-schema pointer="{{derived.$ref}}" [final]="derived.final" class="discriminator-part">
<json-schema [childFor]="pointer" pointer="{{derived.$ref}}" [final]="derived.final" class="discriminator-part">
</json-schema>
</div>
</td>

View File

@ -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;