Skip to content

API V2: Inconsistent 'add' behavior for empty arrays #224

@CamilleLetavernier

Description

@CamilleLetavernier

Empty arrays are handled differently in EMF and Json. For example, these 2 models are equivalent in EMF (because lists are never "null"; they default to an empty collection), but different in Json:

{
  "array": []
}
{
}

In the first case, we can add an array value with this patch:

{
  "op": "add",
  "path": "/array/-",
  "value": "newValue"
}

In the second case, we need to add the entire array to the root node:

{
  "op": "add",
  "path": "/array",
  "value": ["newValue"]
}

The JsonPatchHelper doesn't support the latter case (index-less "add" operation with a full array value). We should support direct feature edition (/array instead of /array/-) for arrays , and expect an array value in that case ([value1, value2] instead of value1).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmodelserverEMF.cloud Model Serverv2

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions