Skip to content

Commit 23a72c3

Browse files
authored
fix(specs): correct type for highlightResult and snippetResult (#783)
1 parent 7e091cf commit 23a72c3

File tree

5 files changed

+58
-19
lines changed

5 files changed

+58
-19
lines changed

scripts/ci/husky/pre-commit.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function getPatterns() {
2525
return patterns;
2626
}
2727

28-
async function preCommit() {
28+
async function preCommit(log) {
2929
// when merging, we want to stage all the files
3030
try {
3131
await run('git merge HEAD');
@@ -45,17 +45,22 @@ async function preCommit() {
4545
return;
4646
}
4747

48-
toUnstage.forEach((file) =>
49-
console.log(
50-
chalk.black.bgYellow('[INFO]'),
51-
`Generated file found, unstaging: ${file}`
52-
)
53-
);
48+
if (log) {
49+
toUnstage.forEach((file) =>
50+
console.log(
51+
chalk.black.bgYellow('[INFO]'),
52+
`Generated file found, unstaging: ${file}`
53+
)
54+
);
55+
}
5456
await run(`git restore --staged ${toUnstage.join(' ')}`);
5557
}
5658

5759
if (require.main === module && process.env.CI !== 'true') {
58-
preCommit();
60+
preCommit(true).then(() => {
61+
// Run it twice because of renamed files, the first one delete the renamed one and leaves the deleted file, which is removed by this second pass
62+
preCommit(false);
63+
});
5964
}
6065

6166
module.exports = { getPatterns };

specs/recommend/common/schemas/RecommendationsResponse.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ recommendHit:
2323
objectID:
2424
$ref: '../../../common/parameters.yml#/objectID'
2525
_highlightResult:
26-
$ref: '../../../search/common/schemas/Hit.yml#/highlightResult'
26+
$ref: '../../../search/common/schemas/Hit.yml#/highlightResultMap'
2727
_snippetResult:
28-
$ref: '../../../search/common/schemas/Hit.yml#/snippetResult'
28+
$ref: '../../../search/common/schemas/Hit.yml#/snippetResultMap'
2929
_rankingInfo:
3030
$ref: '../../../search/common/schemas/Hit.yml#/rankingInfo'
3131
_distinctSeqID:

specs/search/common/schemas/Hit.yml

+39-5
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ hit:
88
objectID:
99
$ref: '../../../common/parameters.yml#/objectID'
1010
_highlightResult:
11-
$ref: '#/highlightResult'
11+
$ref: '#/highlightResultMap'
1212
_snippetResult:
13-
$ref: '#/snippetResult'
13+
$ref: '#/snippetResultMap'
1414
_rankingInfo:
1515
$ref: '#/rankingInfo'
1616
_distinctSeqID:
@@ -20,9 +20,9 @@ hit:
2020
_distinctSeqID:
2121
type: integer
2222

23-
highlightResult:
23+
highlightResultOption:
2424
type: object
25-
description: Highlighted attributes.
25+
description: Show highlighted section and words matched on a query.
2626
additionalProperties: false
2727
properties:
2828
value:
@@ -37,15 +37,49 @@ highlightResult:
3737
fullyHighlighted:
3838
type: boolean
3939
description: Whether the entire attribute value is highlighted.
40+
required:
41+
- value
42+
- matchLevel
43+
- matchedWords
4044

41-
snippetResult:
45+
highlightResult:
46+
oneOf:
47+
- $ref: '#/highlightResultOption'
48+
- type: array
49+
items:
50+
$ref: '#/highlightResultOption'
51+
52+
highlightResultMap:
53+
type: object
54+
description: Show highlighted section and words matched on a query.
55+
additionalProperties:
56+
$ref: '#/highlightResult'
57+
58+
snippetResultOption:
4259
type: object
60+
description: Snippeted attributes show parts of the matched attributes. Only returned when attributesToSnippet is non-empty.
4361
additionalProperties: false
4462
properties:
4563
value:
4664
$ref: '#/highlightedValue'
4765
matchLevel:
4866
$ref: '#/matchLevel'
67+
required:
68+
- value
69+
- matchLevel
70+
71+
snippetResult:
72+
oneOf:
73+
- $ref: '#/snippetResultOption'
74+
- type: array
75+
items:
76+
$ref: '#/snippetResultOption'
77+
78+
snippetResultMap:
79+
type: object
80+
description: Snippeted attributes show parts of the matched attributes. Only returned when attributesToSnippet is non-empty.
81+
additionalProperties:
82+
$ref: '#/snippetResult'
4983

5084
rankingInfo:
5185
type: object

specs/search/paths/multiclusters/searchUserIds.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ post:
6767
type: object
6868
properties:
6969
userID:
70-
$ref: '../../common/schemas/Hit.yml#/highlightResult'
70+
$ref: '../../common/schemas/Hit.yml#/highlightResultMap'
7171
clusterName:
72-
$ref: '../../common/schemas/Hit.yml#/highlightResult'
72+
$ref: '../../common/schemas/Hit.yml#/highlightResultMap'
7373
required:
7474
- userID
7575
- clusterName

specs/search/paths/synonyms/common/schemas.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ synonymHit:
4545
additionalProperties: false
4646
properties:
4747
type:
48-
$ref: '../../../common/schemas/Hit.yml#/highlightResult'
48+
$ref: '../../../common/schemas/Hit.yml#/highlightResultMap'
4949
synonyms:
5050
type: array
5151
items:
52-
$ref: '../../../common/schemas/Hit.yml#/highlightResult'
52+
$ref: '../../../common/schemas/Hit.yml#/highlightResultMap'
5353
required:
5454
- objectID
5555
- type

0 commit comments

Comments
 (0)