Class OpenapiResponseValidator

java.lang.Object
ch.nexsol.gateway.validation.OpenapiResponseValidator

public class OpenapiResponseValidator extends Object
Validates a response against the operation the contract resolved for the request: that the status is one the contract declares, that the headers it requires are there, and that the body honours the declared schema.
  • Constructor Details

    • OpenapiResponseValidator

      public OpenapiResponseValidator()
  • Method Details

    • validate

      public ValidationReport validate(OpenapiContract contract, String operationKey, OpenapiContract.Resolution.Found found, int statusCode, org.springframework.http.HttpHeaders headers, byte[] body)
      Validates a response against the contract.
      Parameters:
      contract - the contract the schemas are compiled from
      operationKey - the operation, as METHOD /template, used to key the compiled schemas
      found - the operation the request was resolved to
      statusCode - the status the downstream service answered with
      headers - the response headers
      body - the raw response body, empty when the response carries none, and null when it was not read
      Returns:
      the violations found