Don't generate top-level oneOf for multiple top-levels. Fixes #860

This commit is contained in:
Mark Probst 2018-05-17 17:53:27 -07:00
Родитель bd94e678e1
Коммит a45e6d7640
1 изменённых файлов: 3 добавлений и 5 удалений

Просмотреть файл

@ -189,11 +189,9 @@ export class JSONSchemaRenderer extends ConvenienceRenderer {
}
protected emitSourceStructure(): void {
// FIXME: Find a better way to do multiple top-levels. Maybe multiple files?
const schema = Object.assign(
{ $schema: "http://json-schema.org/draft-06/schema#" },
this.makeOneOf(this.topLevels.toList())
);
// FIXME: Find a good way to do multiple top-levels. Maybe multiple files?
const topLevelType = this.topLevels.size === 1 ? this.schemaForType(defined(this.topLevels.first())) : {};
const schema = Object.assign({ $schema: "http://json-schema.org/draft-06/schema#" }, topLevelType);
const definitions: { [name: string]: Schema } = {};
this.forEachObject("none", (o: ObjectType, name: Name) => {
const title = defined(this.names.get(name));