Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marusyk/simple.httppatch
Simple.HttpPatch implementation for .NET to easily allow & apply partial REST-ful service (through Web API) using Http Patch
https://github.com/marusyk/simple.httppatch
hacktoberfest http-patch json patch rest restful-api webapi
Last synced: about 2 months ago
JSON representation
Simple.HttpPatch implementation for .NET to easily allow & apply partial REST-ful service (through Web API) using Http Patch
- Host: GitHub
- URL: https://github.com/marusyk/simple.httppatch
- Owner: Marusyk
- License: mit
- Created: 2017-09-29T14:53:31.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-19T07:06:43.000Z (2 months ago)
- Last Synced: 2024-11-01T13:42:08.412Z (about 2 months ago)
- Topics: hacktoberfest, http-patch, json, patch, rest, restful-api, webapi
- Language: C#
- Homepage:
- Size: 55.7 KB
- Stars: 18
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[![AppVeyor](https://ci.appveyor.com/api/projects/status/8sq80lyqcatsnssy?svg=true)](https://ci.appveyor.com/project/Marusyk/simple-httppatch) [![GitHub (pre-)release](https://img.shields.io/github/release/Marusyk/Simple.HttpPatch/all.svg)](https://github.com/Marusyk/Simple.HttpPatch/releases/tag/v1.0.0-beta) [![NuGet Pre Release](https://img.shields.io/nuget/vpre/Simple.HttpPatch.svg)](https://www.nuget.org/packages/Simple.HttpPatch)
[![NuGet](https://img.shields.io/nuget/dt/Simple.HttpPatch.svg)]()
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md) ![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)# Simple.HttpPatch [![Stand With Ukraine](https://img.shields.io/badge/made_in-ukraine-ffd700.svg?labelColor=0057b7)](https://stand-with-ukraine.pp.ua)
Simple.HttpPatch is implementation for .NET (Full framework and Core) to easily allow & apply partial RESTful service (through Web API) using [HTTP PATCH](https://tools.ietf.org/html/rfc5789) method.
## Installation
You can install the latest version via [NuGet](https://www.nuget.org/packages/Simple.HttpPatch/).
`PM> Install-Package Simple.HttpPatch`
## How to use
See [samples](https://github.com/Marusyk/Simple.HttpPatch/tree/master/samples/Simple.HttpPatch.Samples) folder to learn of to use this library with ASP.NET Core.
Patch a single entity
```C#
[HttpPatch]
public Person Patch([FromBody] Patch personPatch)
{
var person = _repo.GetPersonById(1);
personPatch.Apply(person);
return person;
}
```To exclude properties of an entity while applying the changes to the original entity use `PatchIgnoreAttribute`.
When your property is a reference type (which allows null) but you don't want that null overwrites your previous stored data then use `PatchIgnoreNullAttribute````C#
public class Person
{
public int Id { get; set; }
[PatchIgnore]
public string Name { get; set; }
public int? Age { get; set; }
[PatchIgnoreNull]
public DateTime BirthDate { get; set; }
}
```*Note: The property with name `Id` is excluded by default*
For firewalls that don't support `PATCH` see [this issue](https://github.com/Marusyk/Simple.HttpPatch/issues/5)
## ContributingPlease read [CONTRIBUTING.md](https://github.com/Marusyk/Simple.HttpPatch/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
## License
This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/Marusyk/Simple.HttpPatch/blob/master/LICENSE) file for details