An open API service indexing awesome lists of open source software.

https://github.com/bright/patchy

A Spring method argument resolver that is suitable for PATCH handling combined with validation
https://github.com/bright/patchy

Last synced: 2 months ago
JSON representation

A Spring method argument resolver that is suitable for PATCH handling combined with validation

Awesome Lists containing this project

README

          

# patchy
A Spring method argument resolver that is suitable for [PATCH](https://tools.ietf.org/html/rfc5789) handling combined with validation.

This simple library let's you apply client provided changes to an entity while at the same time keep the benefits of request validation:

```
class Request : PatchyRequest {
@get:NotBlank
val firstName:String? by { _changes }

@get:NotBlank
val lastName:String? by { _changes }

override var _changes = mapOf()
}

@RestController
class PatchingCtrl {
@RequestMapping("/", method = arrayOf(RequestMethod.PATCH))
fun update(@Valid request: Request){
request.applyChangesTo(entity)
}
}
```

## Setup

`build.gradle`:

```
repositories {
jcenter()
maven { url "https://jitpack.io" }
}

dependencies {
compile 'com.github.bright:patchy:v0.1.0'
...
}
```

Then import the configuration with:
```
@SpringBootApplication
@EnableWebMvc
@Import(PatchyConfiguration::class)
open class Application {
```