Skip to content

Commit

Permalink
fix: fix oneOf/anyOf titles
Browse files Browse the repository at this point in the history
fixes #618, #621
  • Loading branch information
RomanHotsiy committed Aug 24, 2018
1 parent a5f9f6b commit 39b930d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/services/models/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,24 @@ export class SchemaModel {
parser,
{
// 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,
this.pointer + '/oneOf/' + idx,
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(
Expand Down

0 comments on commit 39b930d

Please sign in to comment.