From an patch json object as defined in RFC 7644, applies the operations into an object instance.
$ dotnet add package ScimPatchScimPatch is an open source implementation to facilitate the use of SCIM V2 patch in .net projects.
With this, from a JsonPatch object, we can apply the list of operations on c# objects.
As described in RFC7644:
The general form of the SCIM PATCH request is based on JSON Patch RFC6902. One difference between SCIM PATCH and JSON Patch is that SCIM servers do not support array indexing and do not support RFC6902 operation types relating to array element manipulation, such as "move".
Install latest version via package manager:
dotnet add package ScimPatch
For a json with an array of operations:
[
{
"op": "add",
"path": "IntProperty",
"value": 123
},
{
"op": "remove",
"path": "NullableBoolProperty"
}
]
We just need to parse to the equivalent OperationNodes:
List<bool> results = [];
var operations = OperationTracker.FromJson(targetObject, json);
foreach (var operationNode in operations)
{
results.Add(await operationNode.TryApplyAsync());
}
After that, the targetObject will have all modifications in memory.
You can code your models (target objects) such that it keeks the state of modified properties so you only persist on your storage what is necessary.
For more detailed examples, refer to the samples project at the repository page.
This project is licensed under the Apache 2.0.
See LICENSE.md for more information.
We welcome contributions! Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo, make changes and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
This GitHub repository adheres to the principles of GitHub Flow as outlined in the official GitHub documentation. We ensure that all changes are made through branch-based workflows, enabling collaborative development and efficient code review before integration into the main branch.
gitGraph
commit id:"fix(api): export endpoint should be consistent with output clause"
branch feature/amazing
checkout feature/amazing
commit id:"feat(amazing): implement mvp"
checkout main
merge feature/amazing
branch hotfix/cicd
checkout hotfix/cicd
commit id:"fix(cicd): automatic deployment"
checkout main
merge hotfix/cicd
branch feature/incredible
checkout feature/incredible
commit id:"feat(incredible): implement mvp"
checkout main
merge feature/incrediblegit checkout -b feature/amazing)npm run commit)git push origin feature/amazing)If you have any questions or feedback, feel free to reach out: