Class OpenapiRequestValidator

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

public class OpenapiRequestValidator extends Object
Validates a request against the operation the contract resolved for it: its parameters first, then its body.
  • Constructor Details

    • OpenapiRequestValidator

      public OpenapiRequestValidator()
  • Method Details

    • validateParameters

      public ValidationReport validateParameters(OpenapiContract contract, String operationKey, OpenapiContract.Resolution.Found found, org.springframework.http.server.reactive.ServerHttpRequest request)
      Validates the path, query, header and cookie parameters the contract declares for the operation.
      Parameters:
      contract - the contract the schemas are compiled from
      operationKey - the operation, as METHOD /template, used to key the compiled schemas
      found - the resolved operation
      request - the request being validated
      Returns:
      the violations found
    • validateBody

      public ValidationReport validateBody(OpenapiContract contract, String operationKey, OpenapiContract.Resolution.Found found, org.springframework.http.MediaType contentType, byte[] body)
      Validates the request body against the schema the contract declares for the operation.
      Parameters:
      contract - the contract the schemas are compiled from
      operationKey - the operation, as METHOD /template, used to key the compiled schemas
      found - the resolved operation
      contentType - the request media type, may be null
      body - the raw request body, empty when the request carries none
      Returns:
      the violations found