File tree Expand file tree Collapse file tree 3 files changed +26
-14
lines changed
openapi-validation-core/src/main/java/com/getyourguide/openapi/validation/core
spring-boot-starter-webflux-spring2.7/src/main/java/com/getyourguide/openapi/validation/filter/decorator
spring-boot-starter-webflux/src/main/java/com/getyourguide/openapi/validation/filter/decorator Expand file tree Collapse file tree 3 files changed +26
-14
lines changed Original file line number Diff line number Diff line change @@ -83,8 +83,6 @@ private OpenApiViolation buildOpenApiViolation(
83
83
private boolean isViolationExcluded (OpenApiViolation openApiViolation ) {
84
84
return
85
85
violationExclusions .isExcluded (openApiViolation )
86
- // JSON parse errors should be ignored as it can't be compared to the schema then (this also prevents logging personal data!)
87
- || openApiViolation .getMessage ().startsWith ("Unable to parse JSON" )
88
86
// If it matches more than 1, then we don't want to log a validation error
89
87
|| openApiViolation .getMessage ().matches (
90
88
".*\\ [Path '[^']+'] Instance failed to match exactly one schema \\ (matched [1-9][0-9]* out of \\ d\\ ).*" );
Original file line number Diff line number Diff line change 10
10
import org .springframework .http .server .reactive .ServerHttpRequestDecorator ;
11
11
import org .springframework .lang .NonNull ;
12
12
import reactor .core .publisher .Flux ;
13
+ import reactor .core .publisher .SignalType ;
13
14
14
15
public class BodyCachingServerHttpRequestDecorator extends ServerHttpRequestDecorator {
15
16
private final TrafficSelector trafficSelector ;
@@ -38,11 +39,17 @@ public Flux<DataBuffer> getBody() {
38
39
return super .getBody ();
39
40
}
40
41
41
- return super .getBody ().doOnNext (dataBuffer -> {
42
- cachedBody = dataBuffer .toString (StandardCharsets .UTF_8 );
43
- if (onBodyCachedListener != null ) {
44
- onBodyCachedListener .run ();
45
- }
46
- });
42
+ return super .getBody ()
43
+ .doOnNext (dataBuffer -> {
44
+ if (cachedBody == null ) {
45
+ cachedBody = "" ;
46
+ }
47
+ cachedBody += dataBuffer .toString (StandardCharsets .UTF_8 );
48
+ })
49
+ .doFinally (signalType -> {
50
+ if (signalType == SignalType .ON_COMPLETE && onBodyCachedListener != null ) {
51
+ onBodyCachedListener .run ();
52
+ }
53
+ });
47
54
}
48
55
}
Original file line number Diff line number Diff line change 10
10
import org .springframework .http .server .reactive .ServerHttpRequestDecorator ;
11
11
import org .springframework .lang .NonNull ;
12
12
import reactor .core .publisher .Flux ;
13
+ import reactor .core .publisher .SignalType ;
13
14
14
15
public class BodyCachingServerHttpRequestDecorator extends ServerHttpRequestDecorator {
15
16
private final TrafficSelector trafficSelector ;
@@ -38,11 +39,17 @@ public Flux<DataBuffer> getBody() {
38
39
return super .getBody ();
39
40
}
40
41
41
- return super .getBody ().doOnNext (dataBuffer -> {
42
- cachedBody = dataBuffer .toString (StandardCharsets .UTF_8 );
43
- if (onBodyCachedListener != null ) {
44
- onBodyCachedListener .run ();
45
- }
46
- });
42
+ return super .getBody ()
43
+ .doOnNext (dataBuffer -> {
44
+ if (cachedBody == null ) {
45
+ cachedBody = "" ;
46
+ }
47
+ cachedBody += dataBuffer .toString (StandardCharsets .UTF_8 );
48
+ })
49
+ .doFinally (signalType -> {
50
+ if (signalType == SignalType .ON_COMPLETE && onBodyCachedListener != null ) {
51
+ onBodyCachedListener .run ();
52
+ }
53
+ });
47
54
}
48
55
}
You can’t perform that action at this time.
0 commit comments