Skip to content

Commit

Permalink
fix: serde with custom problem
Browse files Browse the repository at this point in the history
related to: Micronaut Serde Jackson with @JsonUnwrapped and @JsonIgnoreProperties doesn't work #233
see: micronaut-projects/micronaut-serialization#233

Compileation fails:

```
$ /problem-json/src/main/java/io/micronaut/problem/ProblemErrorResponseProcessor.java:136: error: Unwrapped property contains a property [type] that conflicts with an existing property of the outer type: io.micronaut.problem.ProblemErrorResponseProcessor$ThrowableProblemWithoutStacktrace. Consider specifying a prefix or suffix to disambiguate this conflict.
        final ThrowableProblem problem;
                               ^
```
  • Loading branch information
sdelamo committed Sep 2, 2022
1 parent a1c75a0 commit 5e6865a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import io.micronaut.core.annotation.Introspected;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.http.HttpMethod;
import io.micronaut.http.HttpStatus;
Expand All @@ -27,6 +26,7 @@
import io.micronaut.http.server.exceptions.response.ErrorResponseProcessor;
import io.micronaut.problem.conf.ProblemConfiguration;
import io.micronaut.problem.conf.ProblemConfigurationProperties;
import io.micronaut.serde.annotation.Serdeable;
import io.micronaut.web.router.exceptions.UnsatisfiedRouteException;
import jakarta.inject.Inject;
import org.zalando.problem.Problem;
Expand Down Expand Up @@ -129,7 +129,7 @@ protected boolean includeErrorMessage(@NonNull ErrorContext errorContext) {
.orElse(false);
}

@Introspected
@Serdeable
static final class ThrowableProblemWithoutStacktrace implements Problem {
@JsonUnwrapped
@JsonIgnoreProperties(value = {"stackTrace", "localizedMessage", "message", "type", "title", "status", "detail", "instance", "parameters"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import io.micronaut.serde.annotation.Serdeable;
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.zalando.problem.AbstractThrowableProblem;

Expand All @@ -31,7 +30,6 @@ class ProblemCustomTest {
HttpClient httpClient;

@Test
@Disabled("pending fix for https://github.com/micronaut-projects/micronaut-problem-json/issues/176")
void customProblemAreSerializedWithSerde() {
HttpClientResponseException e = assertThrows(HttpClientResponseException.class,
() -> httpClient.toBlocking().exchange(HttpRequest.GET("/product/problem"))
Expand Down

0 comments on commit 5e6865a

Please sign in to comment.