View Source OpenApiSpex.TestAssertions (open_api_spex v3.21.2)

Defines helpers for testing API responses and examples against API spec schemas.

Summary

Functions

Asserts that the response body conforms to the response schema for the operation with id operation_id.

Asserts that value conforms to the schema or reference definition.

Asserts that value is a valid request schema with title schema_title in api_spec. In this case, the presence of required readOnly fields is not validated.

Asserts that value is a valid response schema with title schema_title in api_spec. In this case, the presence of required writeOnly fields is not validated.

Asserts that value conforms to the schema in the given %Cast{} context.

Asserts that value conforms to the schema with title schema_title in api_spec.

Functions

Link to this function

assert_operation_response(conn, operation_id \\ nil)

View Source
@spec assert_operation_response(Plug.Conn.t(), String.t() | nil) :: Plug.Conn.t()

Asserts that the response body conforms to the response schema for the operation with id operation_id.

Link to this function

assert_raw_schema(value, schema, spec \\ %{})

View Source
@spec assert_raw_schema(
  term(),
  OpenApiSpex.Schema.t() | OpenApiSpex.Reference.t(),
  OpenApiSpex.OpenApi.t() | %{}
) :: term() | no_return()

Asserts that value conforms to the schema or reference definition.

Link to this function

assert_request_schema(value, schema_title, api_spec)

View Source
@spec assert_request_schema(term(), String.t(), OpenApiSpex.OpenApi.t()) ::
  term() | no_return()

Asserts that value is a valid request schema with title schema_title in api_spec. In this case, the presence of required readOnly fields is not validated.

Link to this function

assert_response_schema(value, schema_title, api_spec)

View Source
@spec assert_response_schema(term(), String.t(), OpenApiSpex.OpenApi.t()) ::
  term() | no_return()

Asserts that value is a valid response schema with title schema_title in api_spec. In this case, the presence of required writeOnly fields is not validated.

Link to this function

assert_schema(cast_context)

View Source
@spec assert_schema(OpenApiSpex.Cast.t()) :: term()

Asserts that value conforms to the schema in the given %Cast{} context.

Link to this function

assert_schema(value, schema_title, api_spec, read_write_scope \\ nil)

View Source

Asserts that value conforms to the schema with title schema_title in api_spec.