diff --git a/specs/common/schemas/SearchParams.yml b/specs/common/schemas/SearchParams.yml index 425e0a3478..a3fe5efd30 100644 --- a/specs/common/schemas/SearchParams.yml +++ b/specs/common/schemas/SearchParams.yml @@ -136,11 +136,7 @@ baseSearchParamsWithoutQuery: x-categories: - Personalization userToken: - type: string - description: Associates a [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/) with the current search. - example: '123456' - x-categories: - - Personalization + $ref: '#/userToken' getRankingInfo: type: boolean description: Incidates whether the search response includes [detailed ranking information](https://www.algolia.com/doc/guides/building-search-ui/going-further/backend-search/in-depth/understanding-the-api-response/#ranking-information). @@ -209,6 +205,13 @@ paramsAsString: type: string default: '' +userToken: + type: string + description: Associates a [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/) with the current search. + example: '123456' + x-categories: + - Personalization + query: type: string description: Text to search for in an index. diff --git a/specs/recommend/common/parameters.yml b/specs/recommend/common/parameters.yml index e99d361e38..b626f5ce03 100644 --- a/specs/recommend/common/parameters.yml +++ b/specs/recommend/common/parameters.yml @@ -18,3 +18,11 @@ ObjectID: type: string description: Unique Recommend rule identifier. example: 'a-recommend-rule-id' + +facetName: + type: string + description: Facet name for trending models. + +facetValue: + type: string + description: Facet value for trending models. diff --git a/specs/recommend/common/schemas/RecommendationsQuery.yml b/specs/recommend/common/schemas/RecommendationsQuery.yml index 764c9b9520..63f75a17dc 100644 --- a/specs/recommend/common/schemas/RecommendationsQuery.yml +++ b/specs/recommend/common/schemas/RecommendationsQuery.yml @@ -1,7 +1,7 @@ recommendationsQuery: allOf: - - $ref: '#/baseRecommendationsQuery' - $ref: './RecommendationsRequest.yml#/baseRecommendRequest' + - $ref: '#/baseRecommendationsQuery' baseRecommendationsQuery: type: object diff --git a/specs/recommend/common/schemas/RecommendationsRequest.yml b/specs/recommend/common/schemas/RecommendationsRequest.yml index fea646a6da..35133f2866 100644 --- a/specs/recommend/common/schemas/RecommendationsRequest.yml +++ b/specs/recommend/common/schemas/RecommendationsRequest.yml @@ -1,8 +1,9 @@ recommendationsRequest: oneOf: - - $ref: './TrendingQuery.yml#/trendingItemsQuery' - - $ref: './TrendingQuery.yml#/trendingFacetsQuery' + - $ref: './TrendingItemsQuery.yml#/trendingItemsQuery' + - $ref: './TrendingFacetsQuery.yml#/trendingFacetsQuery' - $ref: './RecommendationsQuery.yml#/recommendationsQuery' + - $ref: './RecommendedForYouQuery.yml#/recommendedForYouQuery' baseRecommendRequest: type: object diff --git a/specs/recommend/common/schemas/RecommendationsResponse.yml b/specs/recommend/common/schemas/RecommendationsResponse.yml index fab535ae54..29b58fc046 100644 --- a/specs/recommend/common/schemas/RecommendationsResponse.yml +++ b/specs/recommend/common/schemas/RecommendationsResponse.yml @@ -1,16 +1,16 @@ -recommendationsResponse: +recommendationsResults: allOf: - $ref: '../../../search/common/schemas/SearchResponse.yml#/baseSearchResponse' - - $ref: '#/recommendHits' + - $ref: '#/recommendationsHits' -recommendHits: +recommendationsHits: type: object additionalProperties: false properties: hits: type: array items: - $ref: '#/recommendHit' + $ref: '#/recommendationsHit' query: $ref: '../../../common/schemas/SearchParams.yml#/query' params: @@ -20,6 +20,11 @@ recommendHits: required: - hits +recommendationsHit: + oneOf: + - $ref: '#/recommendHit' + - $ref: '#/trendingFacetHit' + recommendHit: type: object description: Recommend hit. @@ -39,41 +44,26 @@ recommendHit: _distinctSeqID: $ref: '../../../search/common/schemas/Hit.yml#/_distinctSeqID' _score: - type: number - format: double - minimum: 0 - maximum: 100 - description: Recommendation score. + $ref: '#/recommendScore' -ruleResponse: +trendingFacetHit: type: object - description: Rule object. - additionalProperties: false - properties: - _metadata: - type: object - properties: - lastUpdate: - $ref: '../../../common/responses/common.yml#/updatedAt' - objectID: - type: string - description: Unique identifier for a rule object. - example: 'hide-12345' - conditions: - type: array - description: > - [Conditions](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/#conditions) required to activate a rule. You can use up to 25 conditions per rule. - items: - $ref: '../../../search/paths/rules/common/schemas.yml#/condition' - consequence: - $ref: '../../../search/paths/rules/common/schemas.yml#//consequence' - description: - type: string - description: Description of the rule's purpose. This can be helpful for display in the Algolia dashboard. - example: 'Display a promotional banner' - enabled: - type: boolean - default: true - description: Indicates whether to enable the rule. If it isn't enabled, it isn't applied at query time. + description: Trending facet hit. required: - - objectID + - _score + - facetName + - facetValue + properties: + _score: + $ref: '#/recommendScore' + facetName: + $ref: '../parameters.yml#/facetName' + facetValue: + $ref: '../parameters.yml#/facetValue' + +recommendScore: + type: number + format: double + minimum: 0 + maximum: 100 + description: Recommendation score. diff --git a/specs/recommend/common/schemas/RecommendedForYouQuery.yml b/specs/recommend/common/schemas/RecommendedForYouQuery.yml new file mode 100644 index 0000000000..1289c18e26 --- /dev/null +++ b/specs/recommend/common/schemas/RecommendedForYouQuery.yml @@ -0,0 +1,35 @@ +recommendedForYouQuery: + allOf: + - $ref: './RecommendationsRequest.yml#/baseRecommendRequest' + - $ref: '#/baseRecommendedForYouQuery' + +recommendedForYouQueryParameters: + allOf: + - $ref: '../../../common/schemas/SearchParams.yml#/searchParamsObject' + - $ref: '#/baseRecommendedForYouQueryParameters' + +baseRecommendedForYouQueryParameters: + type: object + properties: + userToken: + $ref: '../../../common/schemas/SearchParams.yml#/userToken' + required: + - userToken + +baseRecommendedForYouQuery: + type: object + additionalProperties: false + properties: + model: + $ref: '#/recommendedForYouModel' + queryParameters: + $ref: '#/recommendedForYouQueryParameters' + fallbackParameters: + $ref: '#/recommendedForYouQueryParameters' + required: + - model + +recommendedForYouModel: + description: Recommended for you model. + type: string + enum: [recommended-for-you] diff --git a/specs/recommend/common/schemas/RuleResponse.yml b/specs/recommend/common/schemas/RuleResponse.yml new file mode 100644 index 0000000000..9690c5a8f4 --- /dev/null +++ b/specs/recommend/common/schemas/RuleResponse.yml @@ -0,0 +1,31 @@ +type: object +description: Rule object. +additionalProperties: false +properties: + _metadata: + type: object + properties: + lastUpdate: + $ref: '../../../common/responses/common.yml#/updatedAt' + objectID: + type: string + description: Unique identifier for a rule object. + example: 'hide-12345' + conditions: + type: array + description: > + [Conditions](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/#conditions) required to activate a rule. You can use up to 25 conditions per rule. + items: + $ref: '../../../search/paths/rules/common/schemas.yml#/condition' + consequence: + $ref: '../../../search/paths/rules/common/schemas.yml#//consequence' + description: + type: string + description: Description of the rule's purpose. This can be helpful for display in the Algolia dashboard. + example: 'Display a promotional banner' + enabled: + type: boolean + default: true + description: Indicates whether to enable the rule. If it isn't enabled, it isn't applied at query time. +required: + - objectID diff --git a/specs/recommend/common/schemas/TrendingFacetsQuery.yml b/specs/recommend/common/schemas/TrendingFacetsQuery.yml new file mode 100644 index 0000000000..a1d67085e8 --- /dev/null +++ b/specs/recommend/common/schemas/TrendingFacetsQuery.yml @@ -0,0 +1,20 @@ +trendingFacetsQuery: + allOf: + - $ref: './RecommendationsRequest.yml#/baseRecommendRequest' + - $ref: '#/baseTrendingFacetsQuery' + +baseTrendingFacetsQuery: + type: object + additionalProperties: false + properties: + facetName: + $ref: '../parameters.yml#/facetName' + model: + $ref: '#/trendingFacetsModel' + required: + - facetName + +trendingFacetsModel: + description: Trending facets model. + type: string + enum: [trending-facets] diff --git a/specs/recommend/common/schemas/TrendingItemsQuery.yml b/specs/recommend/common/schemas/TrendingItemsQuery.yml new file mode 100644 index 0000000000..02a23131c5 --- /dev/null +++ b/specs/recommend/common/schemas/TrendingItemsQuery.yml @@ -0,0 +1,24 @@ +trendingItemsQuery: + allOf: + - $ref: './RecommendationsRequest.yml#/baseRecommendRequest' + - $ref: '#/baseTrendingItemsQuery' + +baseTrendingItemsQuery: + type: object + additionalProperties: false + properties: + facetName: + $ref: '../parameters.yml#/facetName' + facetValue: + $ref: '../parameters.yml#/facetValue' + model: + $ref: '#/trendingItemsModel' + queryParameters: + $ref: '../../../common/schemas/SearchParams.yml#/searchParamsObject' + fallbackParameters: + $ref: '../../../common/schemas/SearchParams.yml#/searchParamsObject' + +trendingItemsModel: + description: Trending items model. + type: string + enum: [trending-items] diff --git a/specs/recommend/common/schemas/TrendingQuery.yml b/specs/recommend/common/schemas/TrendingQuery.yml deleted file mode 100644 index c22ba98ec6..0000000000 --- a/specs/recommend/common/schemas/TrendingQuery.yml +++ /dev/null @@ -1,50 +0,0 @@ -trendingItemsQuery: - allOf: - - $ref: '#/baseTrendingItemsQuery' - - $ref: './RecommendationsRequest.yml#/baseRecommendRequest' - -baseTrendingItemsQuery: - type: object - additionalProperties: false - properties: - facetName: - $ref: '#/facetName' - facetValue: - type: string - description: Facet value for trending models. - model: - $ref: '#/trendingItemsModel' - queryParameters: - $ref: '../../../common/schemas/SearchParams.yml#/searchParamsObject' - fallbackParameters: - $ref: '../../../common/schemas/SearchParams.yml#/searchParamsObject' - -trendingFacetsQuery: - allOf: - - $ref: '#/baseTrendingFacetsQuery' - - $ref: './RecommendationsRequest.yml#/baseRecommendRequest' - -baseTrendingFacetsQuery: - type: object - additionalProperties: false - properties: - facetName: - $ref: '#/facetName' - model: - $ref: '#/trendingFacetsModel' - required: - - facetName - -trendingFacetsModel: - description: Trending facets model. - type: string - enum: [trending-facets] - -trendingItemsModel: - description: Trending items model. - type: string - enum: [trending-items] - -facetName: - type: string - description: Facet name for trending models. diff --git a/specs/recommend/paths/getRecommendations.yml b/specs/recommend/paths/getRecommendations.yml index 7bf45ad150..e4c6440505 100644 --- a/specs/recommend/paths/getRecommendations.yml +++ b/specs/recommend/paths/getRecommendations.yml @@ -40,7 +40,7 @@ post: results: type: array items: - $ref: '../common/schemas/RecommendationsResponse.yml#/recommendationsResponse' + $ref: '../common/schemas/RecommendationsResponse.yml#/recommendationsResults' '400': $ref: '../../common/responses/BadRequest.yml' '402': diff --git a/specs/recommend/paths/recommendRule.yml b/specs/recommend/paths/recommendRule.yml index c271262dc0..a4888aa66f 100644 --- a/specs/recommend/paths/recommendRule.yml +++ b/specs/recommend/paths/recommendRule.yml @@ -14,7 +14,7 @@ get: content: application/json: schema: - $ref: '../common/schemas/RecommendationsResponse.yml#/ruleResponse' + $ref: '../common/schemas/RuleResponse.yml' '400': $ref: '../../common/responses/BadRequest.yml' '402': @@ -44,4 +44,4 @@ delete: '403': $ref: '../../common/responses/MethodNotAllowed.yml' '404': - $ref: '../../common/responses/IndexNotFound.yml' \ No newline at end of file + $ref: '../../common/responses/IndexNotFound.yml' diff --git a/specs/recommend/paths/searchRecommendRules.yml b/specs/recommend/paths/searchRecommendRules.yml index eed612a53d..61c1afb44f 100644 --- a/specs/recommend/paths/searchRecommendRules.yml +++ b/specs/recommend/paths/searchRecommendRules.yml @@ -33,14 +33,6 @@ post: nullable: true default: null description: Restricts responses to enabled rules. When absent (default), _all_ rules are retrieved. - requestOptions: - type: array - description: Request options to send with the API call. - example: > - {timeouts:{read:20}} - items: - type: object - description: Request option. responses: '200': description: OK @@ -60,16 +52,13 @@ post: type: array description: Fetched rules. items: - $ref: '../common/schemas/RecommendationsResponse.yml#/ruleResponse' + $ref: '../common/schemas/RuleResponse.yml' nbHits: - type: integer - description: Number of fetched rules. + $ref: '../../search/common/schemas/SearchResponse.yml#/nbHits' page: - type: integer - description: Current page. + $ref: '../../common/schemas/SearchParams.yml#/page' nbPages: - type: integer - description: Number of pages. + $ref: '../../search/common/schemas/SearchResponse.yml#/nbPages' '400': $ref: '../../common/responses/BadRequest.yml' '402': @@ -77,4 +66,4 @@ post: '403': $ref: '../../common/responses/MethodNotAllowed.yml' '404': - $ref: '../../common/responses/IndexNotFound.yml' \ No newline at end of file + $ref: '../../common/responses/IndexNotFound.yml' diff --git a/templates/java/oneof_interface.mustache b/templates/java/oneof_interface.mustache index ed94fc2399..48401ddadf 100644 --- a/templates/java/oneof_interface.mustache +++ b/templates/java/oneof_interface.mustache @@ -83,7 +83,7 @@ public interface {{classname}}{{#vendorExtensions.x-has-child-generic}}{{/ven JsonNode tree = jp.readValueAsTree(); {{#composedSchemas.oneOf}} // deserialize {{{datatypeWithEnum}}} - if (tree.{{#isMap}}isObject(){{/isMap}}{{#isModel}}isObject(){{#vendorExtensions.x-discriminator-fields}} && tree.has("{{{.}}}"){{/vendorExtensions.x-discriminator-fields}}{{/isModel}}{{#isEnumRef}}isTextual(){{/isEnumRef}}{{#isArray}}isArray(){{/isArray}}{{#isInteger}}isInt(){{/isInteger}}{{#isLong}}isLong(){{/isLong}}{{#isDouble}}isDouble(){{/isDouble}}{{#isBoolean}}isBoolean(){{/isBoolean}}{{#isString}}isTextual(){{/isString}}){ + if (tree.{{#isModel}}isObject(){{#vendorExtensions.x-discriminator-fields}} && tree.has("{{{.}}}"){{/vendorExtensions.x-discriminator-fields}}{{/isModel}}{{#isEnumRef}}isTextual(){{/isEnumRef}}{{#isArray}}isArray(){{/isArray}}{{#isInteger}}isInt(){{/isInteger}}{{#isLong}}isLong(){{/isLong}}{{#isDouble}}isDouble(){{/isDouble}}{{#isBoolean}}isBoolean(){{/isBoolean}}{{#isString}}isTextual(){{/isString}}{{^isEnumRef}}{{^isModel}}{{^isArray}}{{^isInteger}}{{^isLong}}{{^isDouble}}{{^isBoolean}}{{^isString}}isObject(){{/isString}}{{/isBoolean}}{{/isDouble}}{{/isLong}}{{/isInteger}}{{/isArray}}{{/isModel}}{{/isEnumRef}}){ try(JsonParser parser = tree.traverse(jp.getCodec())) { {{#isModel}} return parser.readValueAs({{#vendorExtensions.x-has-child-generic}}new TypeReference<{{datatypeWithEnum}}>() {}{{/vendorExtensions.x-has-child-generic}}{{^vendorExtensions.x-has-child-generic}}{{{datatypeWithEnum}}}.class{{/vendorExtensions.x-has-child-generic}}); @@ -125,4 +125,4 @@ public interface {{classname}}{{#vendorExtensions.x-has-child-generic}}{{/ven {{/isNullable}} } } -} +} \ No newline at end of file