Skip to content

Commit d0b38b9

Browse files
authored
fix: require sorting type in fallback sort schema
1 parent 8f2126c commit d0b38b9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

test/utils/common-json-schemas.test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,22 @@ describe('common-json-schemas', () => {
9696
).toBeTruthy()
9797
})
9898

99-
it('should not allow invalid values', () => {
99+
it('should not allow undefined type', () => {
100100
expect(
101101
commonJsonSchemaValidator({
102102
fallbackSort: {
103-
type: 'invalid',
103+
order: 'asc',
104104
},
105105
}),
106106
).toBeFalsy()
107107
})
108108

109-
it('should not allow the empty object', () => {
109+
it('should not allow invalid values', () => {
110110
expect(
111111
commonJsonSchemaValidator({
112-
fallbackSort: {},
112+
fallbackSort: {
113+
type: 'invalid',
114+
},
113115
}),
114116
).toBeFalsy()
115117
})
@@ -120,6 +122,7 @@ describe('common-json-schemas', () => {
120122
expect(
121123
commonJsonSchemaValidator({
122124
fallbackSort: {
125+
type: 'alphabetical',
123126
order,
124127
},
125128
}),
@@ -130,6 +133,7 @@ describe('common-json-schemas', () => {
130133
expect(
131134
commonJsonSchemaValidator({
132135
fallbackSort: {
136+
type: 'alphabetical',
133137
order: 'invalid',
134138
},
135139
}),
@@ -142,6 +146,7 @@ describe('common-json-schemas', () => {
142146
commonJsonSchemaValidator({
143147
fallbackSort: {
144148
somethingElse: 'something',
149+
type: 'alphabetical',
145150
},
146151
}),
147152
).toBeFalsy()

utils/common-json-schemas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function buildFallbackSortJsonSchema({
124124
},
125125
description: 'Fallback sort order.',
126126
additionalProperties: false,
127-
minProperties: 1,
127+
required: ['type'],
128128
type: 'object',
129129
}
130130
}

0 commit comments

Comments
 (0)