Skip to content

Commit 557ccec

Browse files
committed
Added validation expection
1 parent b8a8c59 commit 557ccec

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/main/java/in/erail/route/OpenAPI3RouteBuilder.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,14 @@ public HttpServerResponse buildResponseFromReply(JsonObject pReplyResponse, Rout
183183
.filter(t -> t.isPresent())
184184
.forEach(t -> pContext.addCookie(t.get()));
185185

186-
Optional<byte[]> body = Optional.ofNullable(response.getBody());
186+
Optional<byte[]> body = Optional
187+
.ofNullable(response.getBody());
187188

188189
body.ifPresent((t) -> {
189190
pContext.response().putHeader(HttpHeaderNames.CONTENT_LENGTH.toString(), Integer.toString(t.length));
190191
pContext.response().write(Buffer.buffer(t));
191192
});
193+
192194
return pContext.response();
193195
}
194196

@@ -250,6 +252,18 @@ public Router getRouter(Router pRouter) {
250252
.setStatusCode(400)
251253
.end(routingContext.failure().toString());
252254
});
255+
apiFactory.setValidationFailureHandler((routingContext) -> {
256+
routingContext
257+
.response()
258+
.setStatusCode(400)
259+
.end(routingContext.failure().toString());
260+
});
261+
apiFactory.setNotImplementedFailureHandler((routingContext) -> {
262+
routingContext
263+
.response()
264+
.setStatusCode(400)
265+
.end(routingContext.failure().toString());
266+
});
253267
});
254268
});
255269

0 commit comments

Comments
 (0)