OpenApiSpex.TestAssertions (open_api_spex v3.21.3)

View Source

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

assert_operation_response(conn, operation_id \\ nil)

@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.

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

@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.

assert_request_schema(value, schema_title, api_spec)

@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.

assert_response_schema(value, schema_title, api_spec)

@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.

assert_schema(cast_context)

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

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

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

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