From 7d7b4e3fb870e70b2ed95338769dfbf8bd42ec14 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 12 May 2019 21:38:00 +0300 Subject: [PATCH] fix: incorrect detected schema title for deeply inherited schemas --- src/services/OpenAPIParser.ts | 6 +----- .../__tests__/__snapshots__/OpenAPIParser.test.ts.snap | 4 ++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/OpenAPIParser.ts b/src/services/OpenAPIParser.ts index 37a6e138..b406098f 100644 --- a/src/services/OpenAPIParser.ts +++ b/src/services/OpenAPIParser.ts @@ -187,6 +187,7 @@ export class OpenAPIParser { ...schema, allOf: undefined, parentRefs: [], + title: schema.title || (isNamedDefinition($ref) ? JsonPointer.baseName($ref) : undefined), }; // avoid mutating inner objects @@ -263,11 +264,6 @@ export class OpenAPIParser { } } - // name of definition or title on top level - if (schema.title === undefined && isNamedDefinition($ref)) { - receiver.title = JsonPointer.baseName($ref); - } - return receiver; } diff --git a/src/services/__tests__/__snapshots__/OpenAPIParser.test.ts.snap b/src/services/__tests__/__snapshots__/OpenAPIParser.test.ts.snap index 3ec279e0..74a26ed0 100644 --- a/src/services/__tests__/__snapshots__/OpenAPIParser.test.ts.snap +++ b/src/services/__tests__/__snapshots__/OpenAPIParser.test.ts.snap @@ -21,6 +21,7 @@ Object { "type": "string", }, }, + "title": undefined, }, Object { "allOf": undefined, @@ -38,6 +39,7 @@ Object { "type": "string", }, }, + "title": undefined, }, ], }, @@ -59,6 +61,7 @@ Object { "type": "string", }, }, + "title": undefined, }, Object { "allOf": undefined, @@ -76,6 +79,7 @@ Object { "type": "string", }, }, + "title": undefined, }, ], },