Skip to content

Commit 44abda7

Browse files
fix(json-schema-merge-allof): bump json-schema-merge-allOf version (#28)
BREAKING CHANGE: description and summary reference siblings will not get overwritten by description and summary from the referenced object
1 parent 46d92ce commit 44abda7

File tree

3 files changed

+60
-5
lines changed

3 files changed

+60
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"peerDependencies": {},
3838
"dependencies": {
3939
"@stoplight/json": "^3.12.0",
40-
"@stoplight/json-schema-merge-allof": "^0.7.8",
40+
"@stoplight/json-schema-merge-allof": "^0.8.0",
4141
"@stoplight/lifecycle": "^2.3.2",
4242
"@types/json-schema": "^7.0.7",
4343
"magic-error": "0.0.1"

src/__tests__/tree.spec.ts

+55
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,61 @@ describe('SchemaTree', () => {
787787
).toEqual('_Everyone_ ~hates~ loves caves');
788788
});
789789

790+
it('should not override description reference siblings', () => {
791+
const schema = {
792+
$schema: 'http://json-schema.org/draft-07/schema#',
793+
type: 'object',
794+
properties: {
795+
AAAAA: {
796+
allOf: [{ description: 'AAAAA', type: 'string' }, { examples: ['AAAAA'] }],
797+
},
798+
BBBBB: {
799+
allOf: [
800+
{
801+
$ref: '#/properties/AAAAA/allOf/0',
802+
description: 'BBBBB',
803+
},
804+
{ examples: ['BBBBB'] },
805+
],
806+
},
807+
},
808+
};
809+
810+
const tree = new SchemaTree(schema, {});
811+
tree.populate();
812+
813+
expect(tree.root).toEqual(
814+
expect.objectContaining({
815+
children: [
816+
expect.objectContaining({
817+
primaryType: 'object',
818+
types: ['object'],
819+
children: [
820+
expect.objectContaining({
821+
primaryType: 'string',
822+
subpath: ['properties', 'AAAAA'],
823+
types: ['string'],
824+
annotations: {
825+
description: 'AAAAA',
826+
examples: ['AAAAA'],
827+
},
828+
}),
829+
expect.objectContaining({
830+
primaryType: 'string',
831+
subpath: ['properties', 'BBBBB'],
832+
types: ['string'],
833+
annotations: {
834+
description: 'BBBBB',
835+
examples: ['BBBBB'],
836+
},
837+
}),
838+
],
839+
}),
840+
],
841+
}),
842+
);
843+
});
844+
790845
it('node of type array should keep its own description even when referenced node has a description', () => {
791846
const schema = {
792847
definitions: {

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -936,10 +936,10 @@
936936
dependencies:
937937
eslint-config-prettier "^7.1.0"
938938

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

0 commit comments

Comments
 (0)