Skip to content

Commit 39b930d

Browse files
committed
fix: fix oneOf/anyOf titles
fixes #618, #621
1 parent a5f9f6b commit 39b930d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/services/models/Schema.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,24 @@ export class SchemaModel {
161161
parser,
162162
{
163163
// merge base schema into each of oneOf's subschemas
164-
allOf: [variant, { ...this.schema, oneOf: undefined, anyOf: undefined }],
164+
...variant,
165+
allOf: [{ ...this.schema, oneOf: undefined, anyOf: undefined }],
165166
} as OpenAPISchema,
166167
this.pointer + '/oneOf/' + idx,
167168
this.options,
168169
),
169170
);
170-
this.displayType = this.oneOf.map(schema => schema.displayType).join(' or ');
171+
this.displayType = this.oneOf
172+
.map(schema => {
173+
let name =
174+
schema.typePrefix +
175+
(schema.title ? `${schema.title} (${schema.displayType})` : schema.displayType);
176+
if (name.indexOf(' or ') > -1) {
177+
name = `(${name})`;
178+
}
179+
return name;
180+
})
181+
.join(' or ');
171182
}
172183

173184
private initDiscriminator(

0 commit comments

Comments
 (0)