fix: fix oneOf/anyOf titles

fixes #618, #621
This commit is contained in:
Roman Hotsiy 2018-08-24 11:38:24 +03:00
parent a5f9f6b2cc
commit 39b930d0ee
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -161,13 +161,24 @@ export class SchemaModel {
parser, parser,
{ {
// merge base schema into each of oneOf's subschemas // merge base schema into each of oneOf's subschemas
allOf: [variant, { ...this.schema, oneOf: undefined, anyOf: undefined }], ...variant,
allOf: [{ ...this.schema, oneOf: undefined, anyOf: undefined }],
} as OpenAPISchema, } as OpenAPISchema,
this.pointer + '/oneOf/' + idx, this.pointer + '/oneOf/' + idx,
this.options, this.options,
), ),
); );
this.displayType = this.oneOf.map(schema => schema.displayType).join(' or '); this.displayType = this.oneOf
.map(schema => {
let name =
schema.typePrefix +
(schema.title ? `${schema.title} (${schema.displayType})` : schema.displayType);
if (name.indexOf(' or ') > -1) {
name = `(${name})`;
}
return name;
})
.join(' or ');
} }
private initDiscriminator( private initDiscriminator(