Skip to content

Commit

Permalink
fix: respect description defined on the property level with $ref even…
Browse files Browse the repository at this point in the history
… if referred object has default description (#703)
  • Loading branch information
darklynx authored and RomanHotsiy committed Nov 22, 2018
1 parent 46f5ea7 commit ce87174
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/services/schema-normalizer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit ce87174

Please sign in to comment.