Oaskit.Validation.ResponseValidator (oaskit v0.16.1)

Copy Markdown View Source

Base validation logic for responses, used by the Oaskit.Test helper.

Summary

Functions

Validates the response body and headers against the response defined in the spec module for the given operation and the response status.

Functions

validate_response(resp_data, spec_module, operation_id)

@spec validate_response(Oaskit.Validation.ResponseData.t(), module(), binary()) ::
  {:ok, term()}
  | {:error, JSV.ValidationError.t()}
  | {:error, {:response_headers_errors, [term()]}}

Validates the response body and headers against the response defined in the spec module for the given operation and the response status.

Returns the validated body in an ok tuple, or an error tuple with a JSV.ValidationError for an invalid body or a :response_headers_errors tagged tuple for invalid headers. Raises if the operation does not define a response for the response status.