From 0b0bc99f73031409c94a06c3772b44d181aaceba Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 10 Jan 2018 13:02:32 +0200 Subject: [PATCH] fix: move title propagation to the correct place --- src/services/OpenAPIParser.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/services/OpenAPIParser.ts b/src/services/OpenAPIParser.ts index 56f0593f60..aef61f7316 100644 --- a/src/services/OpenAPIParser.ts +++ b/src/services/OpenAPIParser.ts @@ -191,10 +191,6 @@ export class OpenAPIParser { }; }); - if (receiver.title === undefined && isNamedDefinition($ref)) { - receiver.title = JsonPointer.baseName($ref); - } - for (let { $ref: subSchemaRef, schema: subSchema } of allOfSchemas) { if ( receiver.type !== subSchema.type && @@ -220,17 +216,22 @@ export class OpenAPIParser { receiver.required = (receiver.required || []).concat(subSchema.required); } + // merge rest of constraints + // TODO: do more intelegent merge + receiver = { ...subSchema, ...receiver }; + if (subSchemaRef) { receiver.parentRefs!.push(subSchemaRef); if (receiver.title === undefined && isNamedDefinition(subSchemaRef)) { receiver.title = JsonPointer.baseName(subSchemaRef); } } + } - // merge rest of constraints - // TODO: do more intelegent merge - receiver = { ...subSchema, ...receiver }; + if (receiver.title === undefined && isNamedDefinition($ref)) { + receiver.title = JsonPointer.baseName($ref); } + return receiver; }