GithubHelp home page GithubHelp logo

lincolnb / simple.httppatch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marusyk/simple.httppatch

0.0 0.0 0.0 51 KB

Simple.HttpPatch implementation for .NET to easily allow & apply partial REST-ful service (through Web API) using Http Patch

License: MIT License

C# 50.34% Shell 20.15% PowerShell 29.52%

simple.httppatch's Introduction

HttpPatch

AppVeyor Travis build status GitHub (pre-)release NuGet Pre Release NuGet License contributions welcome

Simple.HttpPatch

Simple.HttpPatch is implementation for .NET (Full framework and Core) to easily allow & apply partial RESTful service (through Web API) using HTTP PATCH method.

Installation

You can install the latest version via NuGet.

PM> Install-Package Simple.HttpPatch

How to use

See samples folder to learn of to use this library with ASP.NET Core.

Patch a single entity

[HttpPatch]
public Person Patch([FromBody] Patch<Person> 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

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

Contributing

Please read 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 file for details

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.