Package org.forgerock.openig.filter
Class OpenApiValidationFilter
- java.lang.Object
-
- org.forgerock.openig.filter.OpenApiValidationFilter
-
- All Implemented Interfaces:
org.forgerock.http.Filter
public class OpenApiValidationFilter extends Object implements org.forgerock.http.Filter
Validates HTTP requests and responses against an OpenAPI (Swagger 2.x / OpenAPI 3.x) specificationRequest validation
If the request fails validation the filter stops processing and delegates to
requestValidationErrorHandlerinstead of forwarding the request downstream. The defaultrequestValidationErrorHandlerreturns400 Bad Request.Response validation
After the downstream handler returns a response, the filter validates it against the spec. Behaviour depends on
failOnResponseViolation:true– delegate toresponseValidationErrorHandler. The default returns503 Service Unavailablefalse(default) – log a warning and pass the original response through.
Heap configuration
{ "name": "myValidator", "type": "OpenApiValidationFilter", "config": { "specFile": "/path/to/openapi.yaml", "failOnResponseViolation": false, "requestValidationErrorHandler": "403BadRequest", "responseValidationErrorHandler": "503ServiceUnavailable" } }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOpenApiValidationFilter.Heaplet
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_OPENAPI_VALIDATION_REPORTKey under which theValidationReportis stored in theAttributesContextbefore delegating to an error handler.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.forgerock.http.HandlerdefaultRequestValidationErrorHandler()static org.forgerock.http.HandlerdefaultResponseValidationErrorHandler()org.forgerock.util.promise.Promise<org.forgerock.http.protocol.Response,org.forgerock.util.promise.NeverThrowsException>filter(org.forgerock.services.context.Context context, org.forgerock.http.protocol.Request request, org.forgerock.http.Handler next)
-
-
-
Field Detail
-
ATTR_OPENAPI_VALIDATION_REPORT
public static final String ATTR_OPENAPI_VALIDATION_REPORT
Key under which theValidationReportis stored in theAttributesContextbefore delegating to an error handler.- See Also:
- Constant Field Values
-
-
Method Detail
-
filter
public org.forgerock.util.promise.Promise<org.forgerock.http.protocol.Response,org.forgerock.util.promise.NeverThrowsException> filter(org.forgerock.services.context.Context context, org.forgerock.http.protocol.Request request, org.forgerock.http.Handler next)- Specified by:
filterin interfaceorg.forgerock.http.Filter
-
defaultRequestValidationErrorHandler
public static org.forgerock.http.Handler defaultRequestValidationErrorHandler()
-
defaultResponseValidationErrorHandler
public static org.forgerock.http.Handler defaultResponseValidationErrorHandler()
-
-