Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(specs): built-in ops accept also int #3450

Merged
merged 5 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private Map<String, Object> 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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
10 changes: 8 additions & 2 deletions specs/search/paths/objects/common/schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 to add, remove, or append, depending on the operation.

attribute:
type: string
description: Value of the attribute to update.
Expand All @@ -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
Expand Down
24 changes: 24 additions & 0 deletions tests/CTS/requests/search/partialUpdateObject.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
{
"testName": "Partial update with string value",
"parameters": {
"indexName": "theIndexName",
"objectID": "uniqueID",
Expand All @@ -26,5 +27,28 @@
"createIfNotExists": "true"
}
}
},
{
"testName": "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
}
}
}
}
]
Loading