From the course: Creating Spring Boot Microservices
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Solution: Add a PATCH endpoint - Spring Boot Tutorial
From the course: Creating Spring Boot Microservices
Solution: Add a PATCH endpoint
(upbeat music) - [Instructor] So here's the solution. We have the PatchMapping. And we do updateWithPatch. And passing in the tourId and the RequestBody of the ratingDto. And basically, if an attribute is not provided, it's considered null. So we have to have the customerId, the validation, say if it's nullable, okay, you're okay, you don't have to pass in a score. So if there's no score passed in, it would pass in an optional of empty. If it does, it get an optional of the score. And then here's an optional of nullable, which you could have a null value in there, or you could actually pass it in a comment. So that's how it invokes that service. And now let's look at the Swagger. So I created already a rating with the customerId 23, gave it a score of 5 and said it was great. Now let's scroll down to the patch. And now I'm going to say, I'm not going to change the comments, it's still great, but they changed their score to 5. And we got it back. It said, okay, it was a 4 of a score…
Contents
-
-
-
-
-
-
-
(Locked)
Choosing the right framework3m 31s
-
Declaring a new RestController6m 29s
-
(Locked)
Create the RestController HTTP POST endpoint7m 31s
-
(Locked)
Create the RestController HTTP GET endpoint3m 23s
-
(Locked)
Create the RestController HTTP PUT, PATCH, and DELETE endpoints3m 34s
-
(Locked)
Challenge: Add a PATCH endpoint1m 6s
-
(Locked)
Solution: Add a PATCH endpoint1m 20s
-
(Locked)
-
-
-
-
-