Skip to content

Commit

Permalink
fix(json-schema-merge-allof): bump json-schema-merge-allOf version (#28)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: description and summary reference siblings will not get overwritten by description
and summary from the referenced object
  • Loading branch information
brendarearden authored Dec 14, 2023
1 parent 46d92ce commit 44abda7
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"peerDependencies": {},
"dependencies": {
"@stoplight/json": "^3.12.0",
"@stoplight/json-schema-merge-allof": "^0.7.8",
"@stoplight/json-schema-merge-allof": "^0.8.0",
"@stoplight/lifecycle": "^2.3.2",
"@types/json-schema": "^7.0.7",
"magic-error": "0.0.1"
Expand Down
55 changes: 55 additions & 0 deletions src/__tests__/tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,61 @@ describe('SchemaTree', () => {
).toEqual('_Everyone_ ~hates~ loves caves');
});

it('should not override description reference siblings', () => {
const schema = {
$schema: 'http://json-schema.org/draft-07/schema#',
type: 'object',
properties: {
AAAAA: {
allOf: [{ description: 'AAAAA', type: 'string' }, { examples: ['AAAAA'] }],
},
BBBBB: {
allOf: [
{
$ref: '#/properties/AAAAA/allOf/0',
description: 'BBBBB',
},
{ examples: ['BBBBB'] },
],
},
},
};

const tree = new SchemaTree(schema, {});
tree.populate();

expect(tree.root).toEqual(
expect.objectContaining({
children: [
expect.objectContaining({
primaryType: 'object',
types: ['object'],
children: [
expect.objectContaining({
primaryType: 'string',
subpath: ['properties', 'AAAAA'],
types: ['string'],
annotations: {
description: 'AAAAA',
examples: ['AAAAA'],
},
}),
expect.objectContaining({
primaryType: 'string',
subpath: ['properties', 'BBBBB'],
types: ['string'],
annotations: {
description: 'BBBBB',
examples: ['BBBBB'],
},
}),
],
}),
],
}),
);
});

it('node of type array should keep its own description even when referenced node has a description', () => {
const schema = {
definitions: {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -936,10 +936,10 @@
dependencies:
eslint-config-prettier "^7.1.0"

"@stoplight/json-schema-merge-allof@^0.7.8":
version "0.7.8"
resolved "https://registry.yarnpkg.com/@stoplight/json-schema-merge-allof/-/json-schema-merge-allof-0.7.8.tgz#7efe5e0086dff433eb011f617e82f7295c3de061"
integrity sha512-JTDt6GYpCWQSb7+UW1P91IAp/pcLWis0mmEzWVFcLsrNgtUYK7JLtYYz0ZPSR4QVL0fJ0YQejM+MPq5iNDFO4g==
"@stoplight/json-schema-merge-allof@^0.8.0":
version "0.8.0"
resolved "https://registry.yarnpkg.com/@stoplight/json-schema-merge-allof/-/json-schema-merge-allof-0.8.0.tgz#62f8116f59d9df5a910d037b1965decd2efab472"
integrity sha512-g8e0s43v96Xbzvd8d6KKUuJTO16CS2oJglJrviUi8ASIUxzFvAJqTHWLtGmpTryisQopqg1evXGJfi0+164+Qw==
dependencies:
compute-lcm "^1.1.0"
json-schema-compare "^0.2.2"
Expand Down

0 comments on commit 44abda7

Please sign in to comment.