Skip to content

Commit

Permalink
fix: wrong warnings for $ref not single
Browse files Browse the repository at this point in the history
closes #221
  • Loading branch information
RomanHotsiy committed Mar 9, 2017
1 parent 4899f3e commit 193f4bf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/services/schema-normalizer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -115,7 +116,7 @@ export class AllOfMerger {
defaults(into, subSchema);
subSchema._pointer = tmpPtr;
}
into.discriminator = null;
if (!hadDiscriminator) into.discriminator = null;
into.allOf = null;
}

Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 193f4bf

Please sign in to comment.