diff --git a/src/services/OpenAPIParser.ts b/src/services/OpenAPIParser.ts index 37a6e13887..b406098fde 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 3ec279e0fe..74a26ed094 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, }, ], },