ts-json-schema-generator
Version:
Generate JSON schema from your Typescript sources
24 lines • 901 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const DefinitionType_1 = require("./Type/DefinitionType");
class TopRefNodeParser {
constructor(childNodeParser, fullName, topRef) {
this.childNodeParser = childNodeParser;
this.fullName = fullName;
this.topRef = topRef;
}
createType(node, context) {
const baseType = this.childNodeParser.createType(node, context);
if (this.topRef && !(baseType instanceof DefinitionType_1.DefinitionType)) {
return new DefinitionType_1.DefinitionType(this.fullName, baseType);
}
else if (!this.topRef && baseType instanceof DefinitionType_1.DefinitionType) {
return baseType.getType();
}
else {
return baseType;
}
}
}
exports.TopRefNodeParser = TopRefNodeParser;
//# sourceMappingURL=TopRefNodeParser.js.map