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
- Host: GitHub
- URL: https://github.com/bright/patchy
- Owner: bright
- License: mit
- Created: 2016-05-03T19:11:26.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-05T07:12:34.000Z (about 10 years ago)
- Last Synced: 2025-09-17T04:49:25.562Z (9 months ago)
- Language: Kotlin
- Size: 71.3 KB
- Stars: 10
- Watchers: 7
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 {
```