From e5c73a03293a4bd85e8796444b3664f0faa06c37 Mon Sep 17 00:00:00 2001 From: Vladimir Lyubitelev Date: Thu, 8 Nov 2018 10:22:13 +0100 Subject: [PATCH] respect description defined on the property level with $ref even if referred object has default description --- lib/services/schema-normalizer.service.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/services/schema-normalizer.service.ts b/lib/services/schema-normalizer.service.ts index ca602308..61920096 100644 --- a/lib/services/schema-normalizer.service.ts +++ b/lib/services/schema-normalizer.service.ts @@ -229,11 +229,18 @@ export class SchemaDereferencer { if ( keysCount > 2 || (keysCount === 2 && !schema.description) ) { WarningsService.warn(`Other properties are defined at the same level as $ref at "#${pointer}". ` + 'They are IGNORED according to the JsonSchema spec'); - resolved.description = resolved.description || schema.description; } resolved = this.normalizator.normalize(resolved, $ref); this._refCouner.exit($ref); + + // schema description should always override $ref description + if (schema.description) { + // make a copy of resolved object with updated description, do not globally override the description + resolved = Object.assign({}, resolved); + resolved.description = schema.description; + } + return resolved; } }