diff --git a/src/main/java/org/springframework/hateoas/mediatype/problem/Problem.java b/src/main/java/org/springframework/hateoas/mediatype/problem/Problem.java index 99e79d78..f9a8e406 100644 --- a/src/main/java/org/springframework/hateoas/mediatype/problem/Problem.java +++ b/src/main/java/org/springframework/hateoas/mediatype/problem/Problem.java @@ -195,6 +195,15 @@ public class Problem { return new ExtendedProblem<>(getType(), title, getStatus(), getDetail(), getInstance(), extendedProperties); } + /* + * (non-Javadoc) + * @see org.springframework.hateoas.mediatype.problem.Problem#withStatus(org.springframework.http.HttpStatus) + */ + @Override + public ExtendedProblem withStatus(@Nullable HttpStatus status) { + return new ExtendedProblem<>(getType(), getTitle(), status, getDetail(), getInstance(), extendedProperties); + } + /* * (non-Javadoc) * @see org.springframework.hateoas.mediatype.problem.Problem#withDetail(java.lang.String) diff --git a/src/test/java/org/springframework/hateoas/mediatype/problem/JacksonSerializationTest.java b/src/test/java/org/springframework/hateoas/mediatype/problem/JacksonSerializationTest.java index e4a93b96..64586b13 100644 --- a/src/test/java/org/springframework/hateoas/mediatype/problem/JacksonSerializationTest.java +++ b/src/test/java/org/springframework/hateoas/mediatype/problem/JacksonSerializationTest.java @@ -219,6 +219,7 @@ class JacksonSerializationTest { ExtendedProblem problem = Problem.create(details) .withType(URI.create("https://example.com/probs/out-of-credit")) // .withTitle("You do not have enough credit.") // + .withStatus(HttpStatus.BAD_REQUEST) // .withDetail("Your current balance is 30, but that costs 50.") // .withInstance(URI.create("/account/12345/msgs/abc")); diff --git a/src/test/resources/org/springframework/hateoas/mediatype/problem/extension.json b/src/test/resources/org/springframework/hateoas/mediatype/problem/extension.json index f6f6cd69..bfab6dd4 100644 --- a/src/test/resources/org/springframework/hateoas/mediatype/problem/extension.json +++ b/src/test/resources/org/springframework/hateoas/mediatype/problem/extension.json @@ -4,5 +4,6 @@ "detail" : "Your current balance is 30, but that costs 50.", "instance" : "/account/12345/msgs/abc", "balance" : 30, - "accounts" : [ "/account/12345", "/account/67890" ] + "accounts" : [ "/account/12345", "/account/67890" ], + "status" : 400 } \ No newline at end of file