From 9a38a308fbb3ee368c2253d44b833508cb4fa977 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Sun, 23 Jun 2019 12:46:49 -0700 Subject: [PATCH] de-duplicate children See https://github.com/vega/ts-json-schema-generator/pull/105#issuecomment-504742962 --- src/CircularReferenceTypeFormatter.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CircularReferenceTypeFormatter.ts b/src/CircularReferenceTypeFormatter.ts index c8360dbf4..b2d2e058b 100644 --- a/src/CircularReferenceTypeFormatter.ts +++ b/src/CircularReferenceTypeFormatter.ts @@ -1,6 +1,7 @@ import { Definition } from "./Schema/Definition"; import { SubTypeFormatter } from "./SubTypeFormatter"; import { BaseType } from "./Type/BaseType"; +import { uniqueArray } from "./Utils/uniqueArray"; export class CircularReferenceTypeFormatter implements SubTypeFormatter { private definition = new Map(); @@ -31,7 +32,7 @@ export class CircularReferenceTypeFormatter implements SubTypeFormatter { const children: BaseType[] = []; this.children.set(type, children); - children.push(...this.childTypeFormatter.getChildren(type)); + children.push(...uniqueArray(this.childTypeFormatter.getChildren(type))); return children; } }