fix: make oneOf not skip fields defined alongside

This commit is contained in:
Roman Hotsiy 2017-11-23 16:16:04 +02:00
parent bdf60794f3
commit 334a0a07da
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -147,8 +147,15 @@ export class SchemaModel {
private initOneOf(oneOf: OpenAPISchema[], parser: OpenAPIParser) { private initOneOf(oneOf: OpenAPISchema[], parser: OpenAPIParser) {
this.oneOf = oneOf!.map( this.oneOf = oneOf!.map(
(variant, idx) => (variant, idx) =>
// TODO: merge base schema into each oneOf new SchemaModel(
new SchemaModel(parser, variant, this._$ref + '/oneOf/' + idx, this.options), parser,
{
// merge base schema into each of oneOf's subschemas
allOf: [variant, { ...this.schema, oneOf: undefined, anyOf: undefined }],
} as OpenAPISchema,
this._$ref + '/oneOf/' + idx,
this.options,
),
); );
this.displayType = this.oneOf.map(schema => schema.displayType).join(' or '); this.displayType = this.oneOf.map(schema => schema.displayType).join(' or ');
} }