From 2e19b175a01fe980823e311f74732a0c78c0f240 Mon Sep 17 00:00:00 2001 From: akila94 Date: Thu, 12 Oct 2023 11:09:26 +0530 Subject: [PATCH] Add schema validation report to message context --- .../org/wso2/carbon/apimgt/gateway/APIMgtGatewayConstants.java | 1 + .../carbon/apimgt/gateway/handlers/security/SchemaValidator.java | 1 + 2 files changed, 2 insertions(+) diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/APIMgtGatewayConstants.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/APIMgtGatewayConstants.java index 687912c4d918..04992ab4109b 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/APIMgtGatewayConstants.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/APIMgtGatewayConstants.java @@ -149,6 +149,7 @@ public class APIMgtGatewayConstants { public static final String HTTP_REQUEST_METHOD = "HTTP_METHOD_OBJECT"; public static final String REST_CONTENT_TYPE = "ContentType"; public static final String REST_MESSAGE_TYPE = "messageType"; + public static final String SCHEMA_VALIDATION_REPORT = "schema-validation-report"; /** diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/SchemaValidator.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/SchemaValidator.java index 73db55261f9d..5d9e4542c833 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/SchemaValidator.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/SchemaValidator.java @@ -67,6 +67,7 @@ public boolean handleRequest(MessageContext messageContext) { OpenAPIRequest request = new OpenAPIRequest(messageContext); ValidationReport validationReport = validator.validateRequest(request); + messageContext.setProperty(APIMgtGatewayConstants.SCHEMA_VALIDATION_REPORT, validationReport); if (validationReport.hasErrors()) { StringBuilder finalMessage = new StringBuilder(); for (ValidationReport.Message message : validationReport.getMessages()) {