From 193f4bfb44cab95d0315521a687273b54a632a45 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Thu, 9 Mar 2017 19:58:13 +0200 Subject: [PATCH] fix: wrong warnings for $ref not single closes #221 --- lib/services/schema-normalizer.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/services/schema-normalizer.service.ts b/lib/services/schema-normalizer.service.ts index 433d03a8..4a3881e2 100644 --- a/lib/services/schema-normalizer.service.ts +++ b/lib/services/schema-normalizer.service.ts @@ -99,6 +99,7 @@ class SchemaWalker { export class AllOfMerger { static merge(into, schemas) { into['x-derived-from'] = []; + let hadDiscriminator = !!into.discriminator; for (let i=0; i < schemas.length; i++) { let subSchema = schemas[i]; into['x-derived-from'].push(subSchema._pointer); @@ -115,7 +116,7 @@ export class AllOfMerger { defaults(into, subSchema); subSchema._pointer = tmpPtr; } - into.discriminator = null; + if (!hadDiscriminator) into.discriminator = null; into.allOf = null; } @@ -214,7 +215,8 @@ class SchemaDereferencer { // if resolved schema doesn't have title use name from ref resolved.title = resolved.title || JsonPointer.baseName($ref); - let keysCount = Object.keys(schema).length; + let keysCount = Object.keys(schema).filter(key => !key.startsWith('x-redoc')).length; + 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');