Page MenuHomePhorge

No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None
diff --git a/lib/open_api_spex/test/assertions2.ex b/lib/open_api_spex/test/assertions2.ex
index 501ecb3..9ef82f9 100644
--- a/lib/open_api_spex/test/assertions2.ex
+++ b/lib/open_api_spex/test/assertions2.ex
@@ -1,43 +1,12 @@
defmodule OpenApiSpex.Test.Assertions2 do
@moduledoc """
Defines helpers for testing API responses and examples against API spec schemas.
"""
- import ExUnit.Assertions
- alias OpenApiSpex.{Cast, OpenApi}
- alias OpenApiSpex.Cast.Error
-
- @dialyzer {:no_match, assert_schema: 3}
@doc """
Asserts that `value` conforms to the schema with title `schema_title` in `api_spec`.
"""
@spec assert_schema(map, String.t(), OpenApi.t()) :: map | no_return
@deprecated "Use OpenApiSpex.TestAssertions.assert_schema/3 instead"
- def assert_schema(value = %{}, schema_title, api_spec = %OpenApi{}) do
- schemas = api_spec.components.schemas
- schema = schemas[schema_title]
-
- if !schema do
- flunk("Schema: #{schema_title} not found in #{inspect(Map.keys(schemas))}")
- end
-
- case Cast.cast(schema, value, api_spec.components.schemas) do
- {:ok, data} ->
- data
-
- {:error, errors} ->
- errors =
- Enum.map(errors, fn error ->
- message = Error.message(error)
- path = Error.path_to_string(error)
- "#{message} at #{path}"
- end)
-
- flunk(
- "Value does not conform to schema #{schema_title}: #{Enum.join(errors, "\n")}\n#{
- inspect(value)
- }"
- )
- end
- end
+ defdelegate assert_schema(value, schema_title, api_spec), to: OpenApiSpex.TestAssertions
end

File Metadata

Mime Type
text/x-diff
Expires
Wed, Nov 27, 8:39 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40745
Default Alt Text
(1 KB)

Event Timeline