Skip to content

Commit

Permalink
fix(specs): correct type for highlightResult and snippetResult (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp committed Jul 4, 2022
1 parent 7e091cf commit 23a72c3
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 19 deletions.
21 changes: 13 additions & 8 deletions scripts/ci/husky/pre-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function getPatterns() {
return patterns;
}

async function preCommit() {
async function preCommit(log) {
// when merging, we want to stage all the files
try {
await run('git merge HEAD');
Expand All @@ -45,17 +45,22 @@ async function preCommit() {
return;
}

toUnstage.forEach((file) =>
console.log(
chalk.black.bgYellow('[INFO]'),
`Generated file found, unstaging: ${file}`
)
);
if (log) {
toUnstage.forEach((file) =>
console.log(
chalk.black.bgYellow('[INFO]'),
`Generated file found, unstaging: ${file}`
)
);
}
await run(`git restore --staged ${toUnstage.join(' ')}`);
}

if (require.main === module && process.env.CI !== 'true') {
preCommit();
preCommit(true).then(() => {
// 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
preCommit(false);
});
}

module.exports = { getPatterns };
4 changes: 2 additions & 2 deletions specs/recommend/common/schemas/RecommendationsResponse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ recommendHit:
objectID:
$ref: '../../../common/parameters.yml#/objectID'
_highlightResult:
$ref: '../../../search/common/schemas/Hit.yml#/highlightResult'
$ref: '../../../search/common/schemas/Hit.yml#/highlightResultMap'
_snippetResult:
$ref: '../../../search/common/schemas/Hit.yml#/snippetResult'
$ref: '../../../search/common/schemas/Hit.yml#/snippetResultMap'
_rankingInfo:
$ref: '../../../search/common/schemas/Hit.yml#/rankingInfo'
_distinctSeqID:
Expand Down
44 changes: 39 additions & 5 deletions specs/search/common/schemas/Hit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ hit:
objectID:
$ref: '../../../common/parameters.yml#/objectID'
_highlightResult:
$ref: '#/highlightResult'
$ref: '#/highlightResultMap'
_snippetResult:
$ref: '#/snippetResult'
$ref: '#/snippetResultMap'
_rankingInfo:
$ref: '#/rankingInfo'
_distinctSeqID:
Expand All @@ -20,9 +20,9 @@ hit:
_distinctSeqID:
type: integer

highlightResult:
highlightResultOption:
type: object
description: Highlighted attributes.
description: Show highlighted section and words matched on a query.
additionalProperties: false
properties:
value:
Expand All @@ -37,15 +37,49 @@ highlightResult:
fullyHighlighted:
type: boolean
description: Whether the entire attribute value is highlighted.
required:
- value
- matchLevel
- matchedWords

snippetResult:
highlightResult:
oneOf:
- $ref: '#/highlightResultOption'
- type: array
items:
$ref: '#/highlightResultOption'

highlightResultMap:
type: object
description: Show highlighted section and words matched on a query.
additionalProperties:
$ref: '#/highlightResult'

snippetResultOption:
type: object
description: Snippeted attributes show parts of the matched attributes. Only returned when attributesToSnippet is non-empty.
additionalProperties: false
properties:
value:
$ref: '#/highlightedValue'
matchLevel:
$ref: '#/matchLevel'
required:
- value
- matchLevel

snippetResult:
oneOf:
- $ref: '#/snippetResultOption'
- type: array
items:
$ref: '#/snippetResultOption'

snippetResultMap:
type: object
description: Snippeted attributes show parts of the matched attributes. Only returned when attributesToSnippet is non-empty.
additionalProperties:
$ref: '#/snippetResult'

rankingInfo:
type: object
Expand Down
4 changes: 2 additions & 2 deletions specs/search/paths/multiclusters/searchUserIds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ post:
type: object
properties:
userID:
$ref: '../../common/schemas/Hit.yml#/highlightResult'
$ref: '../../common/schemas/Hit.yml#/highlightResultMap'
clusterName:
$ref: '../../common/schemas/Hit.yml#/highlightResult'
$ref: '../../common/schemas/Hit.yml#/highlightResultMap'
required:
- userID
- clusterName
Expand Down
4 changes: 2 additions & 2 deletions specs/search/paths/synonyms/common/schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ synonymHit:
additionalProperties: false
properties:
type:
$ref: '../../../common/schemas/Hit.yml#/highlightResult'
$ref: '../../../common/schemas/Hit.yml#/highlightResultMap'
synonyms:
type: array
items:
$ref: '../../../common/schemas/Hit.yml#/highlightResult'
$ref: '../../../common/schemas/Hit.yml#/highlightResultMap'
required:
- objectID
- type
Expand Down

0 comments on commit 23a72c3

Please sign in to comment.