pingidentity / scim2

The UnboundID SCIM 2.0 SDK for Java
181 stars 74 forks source link

Serialization of PatchOperation produces JSON that is missing the `op` property #169

Closed joachimLengacher closed 2 years ago

joachimLengacher commented 2 years ago

Describe the bug

Converting PatchOperation back into JSON produces something like

{
    "path":"/displayName",
    "value":"some name",
    "opType":"REPLACE"
}

Problem: the op the attribute is missing while opType is unexpected when de-serializing this back into a PatchOperation instance!

To Reproduce

AddOperation addOperation = new AddOperation(new JsonPointer("/displayName"), new TextNode("some name"));
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(addOperation);

json will contain opType instead of the expected op property.

Expected behavior

The JSON generated with the example above should look as follows:

{
    "path":"/displayName",
    "value":"some name",
    "op":"replace"
}

The problem could easily be solved by adding the following method to PatchOperation

public String getOp() {
    return getOpType().toString();
}

Additional context None.