From aa54f43d3f5f3ab03df2123a51df651ff519ad7c Mon Sep 17 00:00:00 2001 From: Kai Welke Date: Tue, 30 Jul 2024 17:48:49 +0200 Subject: [PATCH 1/5] fix(specs): built-in ops accept also int --- specs/search/paths/objects/common/schemas.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/specs/search/paths/objects/common/schemas.yml b/specs/search/paths/objects/common/schemas.yml index 63c849da6a6..3365caf9067 100644 --- a/specs/search/paths/objects/common/schemas.yml +++ b/specs/search/paths/objects/common/schemas.yml @@ -10,6 +10,13 @@ builtInOperationType: - IncrementSet description: How to change the attribute. +builtInOperationValue: + oneOf: + - type: string + description: A string to append or remove for the `Add`, `Remove`, and `AddUnique` operations. + - type: integer + description: A number fo add, remove, or append, depending on the operation. + attribute: type: string description: Value of the attribute to update. @@ -22,8 +29,7 @@ builtInOperation: _operation: $ref: '#/builtInOperationType' value: - type: string - description: Value that corresponds to the operation, for example an `Increment` or `Decrement` step, or an `Add` or `Remove` value. + $ref: '#/builtInOperationValue' required: - _operation - value From b8712b4778c20798507775b4219c4370de33655c Mon Sep 17 00:00:00 2001 From: Kai Welke Date: Tue, 30 Jul 2024 17:53:22 +0200 Subject: [PATCH 2/5] fix: typo --- specs/search/paths/objects/common/schemas.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/search/paths/objects/common/schemas.yml b/specs/search/paths/objects/common/schemas.yml index 3365caf9067..f6a85137694 100644 --- a/specs/search/paths/objects/common/schemas.yml +++ b/specs/search/paths/objects/common/schemas.yml @@ -15,7 +15,7 @@ builtInOperationValue: - type: string description: A string to append or remove for the `Add`, `Remove`, and `AddUnique` operations. - type: integer - description: A number fo add, remove, or append, depending on the operation. + description: A number to add, remove, or append, depending on the operation. attribute: type: string From e118bceae4a7d6f60390c148ca2f0ab6d74162f7 Mon Sep 17 00:00:00 2001 From: Kai Welke Date: Tue, 30 Jul 2024 17:56:53 +0200 Subject: [PATCH 3/5] add test --- .../requests/search/partialUpdateObject.json | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/CTS/requests/search/partialUpdateObject.json b/tests/CTS/requests/search/partialUpdateObject.json index f6da434e978..c84a615d474 100644 --- a/tests/CTS/requests/search/partialUpdateObject.json +++ b/tests/CTS/requests/search/partialUpdateObject.json @@ -1,5 +1,6 @@ [ { + "requestName": "Partial update with string value", "parameters": { "indexName": "theIndexName", "objectID": "uniqueID", @@ -26,5 +27,28 @@ "createIfNotExists": "true" } } + }, + { + "requestName": "Partial update with integer value", + "parameters": { + "indexName": "theIndexName", + "objectID": "uniqueID", + "attributesToUpdate": { + "attributeId": { + "_operation": "Increment", + "value": 2 + } + } + }, + "request": { + "path": "/1/indexes/theIndexName/uniqueID/partial", + "method": "POST", + "body": { + "attributeId": { + "_operation": "Increment", + "value": 2 + } + } + } } ] From c089d43bf44f76aa0df30e0bd9c27c32d423a65d Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Wed, 31 Jul 2024 10:46:30 +0200 Subject: [PATCH 4/5] fix scala --- .../algolia/codegen/cts/tests/ParametersWithDataType.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/generators/src/main/java/com/algolia/codegen/cts/tests/ParametersWithDataType.java b/generators/src/main/java/com/algolia/codegen/cts/tests/ParametersWithDataType.java index 03d4a1a5b4c..9e98e839a74 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/tests/ParametersWithDataType.java +++ b/generators/src/main/java/com/algolia/codegen/cts/tests/ParametersWithDataType.java @@ -146,7 +146,7 @@ private Map traverseParams( handleEnum(param, testOutput); } else if (spec.getIsModel() || isCodegenModel) { // recursive object - handleModel(paramName, param, testOutput, spec, baseType, parent, depth, isParentFreeFormObject); + handleModel(paramName, param, testOutput, spec, baseType, parent, depth, isParentFreeFormObject, isRequired != null && isRequired); } else if (baseType.equals("Object")) { // not var, no item, pure free form handleObject(paramName, param, testOutput, true, depth); @@ -259,7 +259,8 @@ private void handleModel( String baseType, String parent, int depth, - boolean isParentFreeFormObject + boolean isParentFreeFormObject, + boolean parentIsRequired ) throws CTSException { if (!spec.getHasVars()) { // In this case we might have a complex `allOf`, we will first check if it exists @@ -326,6 +327,8 @@ private void handleModel( oneOfModel.put("x-one-of-explicit-name", useExplicitName); oneOfModel.put("hasWrapper", isList || isString(current) || current.getIsNumber() || current.getIsBoolean()); testOutput.put("oneOfModel", oneOfModel); + // use required from the parent since oneOf don't have that property + testOutput.put("required", parentIsRequired); return; } From 35e78458344505044673061e89092a5398e3130d Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Wed, 31 Jul 2024 10:47:31 +0200 Subject: [PATCH 5/5] fix name --- tests/CTS/requests/search/partialUpdateObject.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CTS/requests/search/partialUpdateObject.json b/tests/CTS/requests/search/partialUpdateObject.json index c84a615d474..7ec765361c7 100644 --- a/tests/CTS/requests/search/partialUpdateObject.json +++ b/tests/CTS/requests/search/partialUpdateObject.json @@ -1,6 +1,6 @@ [ { - "requestName": "Partial update with string value", + "testName": "Partial update with string value", "parameters": { "indexName": "theIndexName", "objectID": "uniqueID", @@ -29,7 +29,7 @@ } }, { - "requestName": "Partial update with integer value", + "testName": "Partial update with integer value", "parameters": { "indexName": "theIndexName", "objectID": "uniqueID",