From e3c6b84017da7a37eec083ce95e88862850028d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Wed, 24 Jul 2024 13:04:26 +0200 Subject: [PATCH] fix(specs): remove cross-specs references (#3412) --- specs/common/responses/common.yml | 5 + specs/common/schemas/Hit.yml | 87 +++++++++++++++++ specs/common/schemas/Rule.yml | 8 ++ .../common/schemas/RecommendRule.yml | 2 +- .../schemas/RecommendationsResponse.yml | 4 +- specs/recommend/paths/getRecommendStatus.yml | 2 +- specs/search/common/enums.yml | 5 - specs/search/common/schemas/Hit.yml | 93 +------------------ specs/search/paths/advanced/getAppTask.yml | 2 +- specs/search/paths/advanced/getTask.yml | 2 +- specs/search/paths/rules/common/schemas.yml | 11 +-- 11 files changed, 109 insertions(+), 112 deletions(-) create mode 100644 specs/common/schemas/Hit.yml create mode 100644 specs/common/schemas/Rule.yml diff --git a/specs/common/responses/common.yml b/specs/common/responses/common.yml index 11c7ecb1c1..645f27bb30 100644 --- a/specs/common/responses/common.yml +++ b/specs/common/responses/common.yml @@ -59,3 +59,8 @@ updatedAtResponse: $ref: '#/taskID' updatedAt: $ref: '#/updatedAt' + +taskStatus: + type: string + enum: [published, notPublished] + description: Task status, `published` if the task is completed, `notPublished` otherwise. diff --git a/specs/common/schemas/Hit.yml b/specs/common/schemas/Hit.yml new file mode 100644 index 0000000000..3bd9d1c756 --- /dev/null +++ b/specs/common/schemas/Hit.yml @@ -0,0 +1,87 @@ +matchedGeoLocation: + type: object + properties: + lat: + type: number + format: double + description: Latitude of the matched location. + lng: + type: number + format: double + description: Longitude of the matched location. + distance: + type: integer + description: Distance between the matched location and the search location (in meters). + +personalization: + type: object + properties: + filtersScore: + type: integer + description: The score of the filters. + rankingScore: + type: integer + description: The score of the ranking. + score: + type: integer + description: The score of the event. + +rankingInfo: + type: object + description: Object with detailed information about the record's ranking. + additionalProperties: false + properties: + filters: + type: integer + minimum: 0 + description: Whether a filter matched the query. + firstMatchedWord: + type: integer + minimum: 0 + description: Position of the first matched word in the best matching attribute of the record. + geoDistance: + type: integer + minimum: 0 + description: Distance between the geo location in the search query and the best matching geo location in the record, divided by the geo precision (in meters). + geoPrecision: + type: integer + minimum: 1 + description: Precision used when computing the geo distance, in meters. + matchedGeoLocation: + $ref: '#/matchedGeoLocation' + personalization: + $ref: '#/personalization' + nbExactWords: + type: integer + minimum: 0 + description: Number of exactly matched words. + nbTypos: + type: integer + minimum: 0 + description: Number of typos encountered when matching the record. + promoted: + type: boolean + description: Whether the record was promoted by a rule. + proximityDistance: + type: integer + minimum: 0 + description: Number of words between multiple matches in the query plus 1. For single word queries, `proximityDistance` is 0. + userScore: + type: integer + description: Overall ranking of the record, expressed as a single integer. This attribute is internal. + words: + type: integer + minimum: 1 + description: Number of matched words. + promotedByReRanking: + type: boolean + description: Whether the record is re-ranked. + required: + - nbTypos + - firstMatchedWord + - geoDistance + - nbExactWords + - userScore + +distinctSeqID: + type: integer diff --git a/specs/common/schemas/Rule.yml b/specs/common/schemas/Rule.yml new file mode 100644 index 0000000000..a702088142 --- /dev/null +++ b/specs/common/schemas/Rule.yml @@ -0,0 +1,8 @@ +context: + type: string + pattern: '[A-Za-z0-9_-]+' + description: | + An additional restriction that only triggers the rule, when the search has the same value as `ruleContexts` parameter. + For example, if `context: mobile`, the rule is only triggered when the search request has a matching `ruleContexts: mobile`. + A rule context must only contain alphanumeric characters. + example: mobile diff --git a/specs/recommend/common/schemas/RecommendRule.yml b/specs/recommend/common/schemas/RecommendRule.yml index a269249f43..ce52034204 100644 --- a/specs/recommend/common/schemas/RecommendRule.yml +++ b/specs/recommend/common/schemas/RecommendRule.yml @@ -33,7 +33,7 @@ Condition: filters: $ref: '../../../common/schemas/SearchParams.yml#/filters' context: - $ref: '../../../search/paths/rules/common/schemas.yml#/context' + $ref: '../../../common/schemas/Rule.yml#/context' Consequence: type: object diff --git a/specs/recommend/common/schemas/RecommendationsResponse.yml b/specs/recommend/common/schemas/RecommendationsResponse.yml index 00e7640318..c71b8f59b3 100644 --- a/specs/recommend/common/schemas/RecommendationsResponse.yml +++ b/specs/recommend/common/schemas/RecommendationsResponse.yml @@ -36,9 +36,9 @@ recommendHit: _snippetResult: $ref: '../../../common/schemas/SnippetResult.yml#/snippetResultMap' _rankingInfo: - $ref: '../../../search/common/schemas/Hit.yml#/rankingInfo' + $ref: '../../../common/schemas/Hit.yml#/rankingInfo' _distinctSeqID: - $ref: '../../../search/common/schemas/Hit.yml#/_distinctSeqID' + $ref: '../../../common/schemas/Hit.yml#/distinctSeqID' _score: $ref: '#/recommendScore' diff --git a/specs/recommend/paths/getRecommendStatus.yml b/specs/recommend/paths/getRecommendStatus.yml index 08620d5b98..f77f38e42d 100644 --- a/specs/recommend/paths/getRecommendStatus.yml +++ b/specs/recommend/paths/getRecommendStatus.yml @@ -31,7 +31,7 @@ get: additionalProperties: false properties: status: - $ref: '../../search/common/enums.yml#/taskStatus' + $ref: '../../common/responses/common.yml#/taskStatus' required: - status '400': diff --git a/specs/search/common/enums.yml b/specs/search/common/enums.yml index 2493379792..f7360d4d00 100644 --- a/specs/search/common/enums.yml +++ b/specs/search/common/enums.yml @@ -32,8 +32,3 @@ logType: type: string enum: [all, query, build, error] default: all - -taskStatus: - type: string - enum: [published, notPublished] - description: Task status, `published` if the task is completed, `notPublished` otherwise. diff --git a/specs/search/common/schemas/Hit.yml b/specs/search/common/schemas/Hit.yml index d5e722f42f..e9eef29a2d 100644 --- a/specs/search/common/schemas/Hit.yml +++ b/specs/search/common/schemas/Hit.yml @@ -16,95 +16,6 @@ hit: _snippetResult: $ref: '../../../common/schemas/SnippetResult.yml#/snippetResultMap' _rankingInfo: - $ref: '#/rankingInfo' + $ref: '../../../common/schemas/Hit.yml#/rankingInfo' _distinctSeqID: - $ref: '#/_distinctSeqID' - -# Props -_distinctSeqID: - type: integer - -rankingInfo: - type: object - description: Object with detailed information about the record's ranking. - additionalProperties: false - properties: - filters: - type: integer - minimum: 0 - description: Whether a filter matched the query. - firstMatchedWord: - type: integer - minimum: 0 - description: Position of the first matched word in the best matching attribute of the record. - geoDistance: - type: integer - minimum: 0 - description: Distance between the geo location in the search query and the best matching geo location in the record, divided by the geo precision (in meters). - geoPrecision: - type: integer - minimum: 1 - description: Precision used when computing the geo distance, in meters. - matchedGeoLocation: - $ref: '#/matchedGeoLocation' - personalization: - $ref: '#/personalization' - nbExactWords: - type: integer - minimum: 0 - description: Number of exactly matched words. - nbTypos: - type: integer - minimum: 0 - description: Number of typos encountered when matching the record. - promoted: - type: boolean - description: Whether the record was promoted by a rule. - proximityDistance: - type: integer - minimum: 0 - description: Number of words between multiple matches in the query plus 1. For single word queries, `proximityDistance` is 0. - userScore: - type: integer - description: Overall ranking of the record, expressed as a single integer. This attribute is internal. - words: - type: integer - minimum: 1 - description: Number of matched words. - promotedByReRanking: - type: boolean - description: Whether the record is re-ranked. - required: - - nbTypos - - firstMatchedWord - - geoDistance - - nbExactWords - - userScore - -matchedGeoLocation: - type: object - properties: - lat: - type: number - format: double - description: Latitude of the matched location. - lng: - type: number - format: double - description: Longitude of the matched location. - distance: - type: integer - description: Distance between the matched location and the search location (in meters). - -personalization: - type: object - properties: - filtersScore: - type: integer - description: The score of the filters. - rankingScore: - type: integer - description: The score of the ranking. - score: - type: integer - description: The score of the event. + $ref: '../../../common/schemas/Hit.yml#/distinctSeqID' diff --git a/specs/search/paths/advanced/getAppTask.yml b/specs/search/paths/advanced/getAppTask.yml index 60fca36a7b..b9bbe111d5 100644 --- a/specs/search/paths/advanced/getAppTask.yml +++ b/specs/search/paths/advanced/getAppTask.yml @@ -27,7 +27,7 @@ get: additionalProperties: false properties: status: - $ref: '../../common/enums.yml#/taskStatus' + $ref: '../../../common/responses/common.yml#/taskStatus' required: - status '400': diff --git a/specs/search/paths/advanced/getTask.yml b/specs/search/paths/advanced/getTask.yml index 73e3f61361..255ddeaaba 100644 --- a/specs/search/paths/advanced/getTask.yml +++ b/specs/search/paths/advanced/getTask.yml @@ -34,7 +34,7 @@ get: additionalProperties: false properties: status: - $ref: '../../common/enums.yml#/taskStatus' + $ref: '../../../common/responses/common.yml#/taskStatus' required: - status '400': diff --git a/specs/search/paths/rules/common/schemas.yml b/specs/search/paths/rules/common/schemas.yml index c170c2340c..d523da9aa6 100644 --- a/specs/search/paths/rules/common/schemas.yml +++ b/specs/search/paths/rules/common/schemas.yml @@ -54,7 +54,7 @@ condition: description: Whether the pattern should match plurals, synonyms, and typos. default: false context: - $ref: '#/context' + $ref: '../../../../common/schemas/Rule.yml#/context' filters: type: string description: | @@ -77,15 +77,6 @@ anchoring: Empty queries are only allowed as pattern with `anchoring: is`. enum: [is, startsWith, endsWith, contains] -context: - type: string - pattern: '[A-Za-z0-9_-]+' - description: | - An additional restriction that only triggers the rule, when the search has the same value as `ruleContexts` parameter. - For example, if `context: mobile`, the rule is only triggered when the search request has a matching `ruleContexts: mobile`. - A rule context must only contain alphanumeric characters. - example: mobile - consequence: type: object description: |