Class ResponseValidator


  • public class ResponseValidator
    extends Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ResponseValidator()  
      ResponseValidator​(com.networknt.schema.SchemaValidatorsConfig config)
      Construct a new request validator with the given schema validator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.networknt.status.Status validateResponse​(io.undertow.server.HttpServerExchange exchange, OpenApiOperation openApiOperation)  
      com.networknt.status.Status validateResponseContent​(Object responseContent, OpenApiOperation openApiOperation, String statusCode, String mediaTypeName)
      validate a given response content object
      com.networknt.status.Status validateResponseContent​(Object responseContent, io.undertow.server.HttpServerExchange exchange)
      validate a given response content object with status code "200" and media content type "application/json" uri, httpMethod, JSON_MEDIA_TYPE("200"), DEFAULT_MEDIA_TYPE("application/json") is to locate the schema to validate
      com.networknt.status.Status validateResponseContent​(Object responseContent, String uri, String httpMethod)
      validate a given response content object with status code "200" and media content type "application/json" uri, httpMethod, JSON_MEDIA_TYPE("200"), DEFAULT_MEDIA_TYPE("application/json") is to locate the schema to validate
      com.networknt.status.Status validateResponseContent​(Object responseContent, String uri, String httpMethod, String statusCode)
      validate a given response content object with media content type "application/json" uri, httpMethod, statusCode, DEFAULT_MEDIA_TYPE is to locate the schema to validate
      com.networknt.status.Status validateResponseContent​(Object responseContent, String uri, String httpMethod, String statusCode, String mediaTypeName)
      validate a given response content object with schema coordinate (uri, httpMethod, statusCode, mediaTypeName) uri, httpMethod, statusCode, mediaTypeName is to locate the schema to validate
    • Constructor Detail

      • ResponseValidator

        public ResponseValidator​(com.networknt.schema.SchemaValidatorsConfig config)
        Construct a new request validator with the given schema validator.
        Parameters:
        config - schema validator configuration
      • ResponseValidator

        public ResponseValidator()
    • Method Detail

      • validateResponseContent

        public com.networknt.status.Status validateResponseContent​(Object responseContent,
                                                                   io.undertow.server.HttpServerExchange exchange)
        validate a given response content object with status code "200" and media content type "application/json" uri, httpMethod, JSON_MEDIA_TYPE("200"), DEFAULT_MEDIA_TYPE("application/json") is to locate the schema to validate
        Parameters:
        responseContent - response content needs to be validated
        exchange - HttpServerExchange in handler
        Returns:
        Status return null if no validation errors
      • validateResponseContent

        public com.networknt.status.Status validateResponseContent​(Object responseContent,
                                                                   String uri,
                                                                   String httpMethod)
        validate a given response content object with status code "200" and media content type "application/json" uri, httpMethod, JSON_MEDIA_TYPE("200"), DEFAULT_MEDIA_TYPE("application/json") is to locate the schema to validate
        Parameters:
        responseContent - response content needs to be validated
        uri - original uri of the request
        httpMethod - eg. "put" or "get"
        Returns:
        Status return null if no validation errors
      • validateResponseContent

        public com.networknt.status.Status validateResponseContent​(Object responseContent,
                                                                   String uri,
                                                                   String httpMethod,
                                                                   String statusCode)
        validate a given response content object with media content type "application/json" uri, httpMethod, statusCode, DEFAULT_MEDIA_TYPE is to locate the schema to validate
        Parameters:
        responseContent - response content needs to be validated
        uri - original uri of the request
        httpMethod - eg. "put" or "get"
        statusCode - eg. 200, 400
        Returns:
        Status return null if no validation errors
      • validateResponseContent

        public com.networknt.status.Status validateResponseContent​(Object responseContent,
                                                                   String uri,
                                                                   String httpMethod,
                                                                   String statusCode,
                                                                   String mediaTypeName)
        validate a given response content object with schema coordinate (uri, httpMethod, statusCode, mediaTypeName) uri, httpMethod, statusCode, mediaTypeName is to locate the schema to validate
        Parameters:
        responseContent - response content needs to be validated
        uri - original uri of the request
        httpMethod - eg. "put" or "get"
        statusCode - eg. 200, 400
        mediaTypeName - eg. "application/json"
        Returns:
        Status return null if no validation errors
      • validateResponseContent

        public com.networknt.status.Status validateResponseContent​(Object responseContent,
                                                                   OpenApiOperation openApiOperation,
                                                                   String statusCode,
                                                                   String mediaTypeName)
        validate a given response content object
        Parameters:
        responseContent - response content needs to be validated
        openApiOperation - OpenApi Operation which is located by uri and httpMethod
        statusCode - eg. 200, 400
        mediaTypeName - eg. "application/json"
        Returns:
        Status return null if no validation errors
      • validateResponse

        public com.networknt.status.Status validateResponse​(io.undertow.server.HttpServerExchange exchange,
                                                            OpenApiOperation openApiOperation)