diff --git a/lib/open_api_spex/cast/all_of.ex b/lib/open_api_spex/cast/all_of.ex index e0f49ced..a71e977f 100644 --- a/lib/open_api_spex/cast/all_of.ex +++ b/lib/open_api_spex/cast/all_of.ex @@ -6,7 +6,7 @@ defmodule OpenApiSpex.Cast.AllOf do def cast(ctx), do: cast_all_of(ctx, nil) - defp cast_all_of(%{schema: %{allOf: [%Schema{} = schema | remaining]}} = ctx, acc) do + defp cast_all_of(%Cast{schema: %{allOf: [%Schema{} = schema | remaining]}} = ctx, acc) do relaxed_schema = %{schema | "x-struct": nil} new_ctx = put_in(ctx.schema.allOf, remaining) @@ -23,7 +23,7 @@ defmodule OpenApiSpex.Cast.AllOf do {:error, errors} -> Cast.error( - %Cast{ctx | errors: ctx.errors ++ errors}, + %{ctx | errors: ctx.errors ++ errors}, {:all_of, to_string(relaxed_schema.title || relaxed_schema.type)} ) end diff --git a/lib/open_api_spex/cast/any_of.ex b/lib/open_api_spex/cast/any_of.ex index 334cf0a2..9d870a05 100644 --- a/lib/open_api_spex/cast/any_of.ex +++ b/lib/open_api_spex/cast/any_of.ex @@ -12,7 +12,7 @@ defmodule OpenApiSpex.Cast.AnyOf do end defp cast_any_of( - %{schema: %{anyOf: [%Schema{} = schema | remaining]}} = ctx, + %Cast{schema: %{anyOf: [%Schema{} = schema | remaining]}} = ctx, failed_schemas, acc ) do @@ -32,7 +32,7 @@ defmodule OpenApiSpex.Cast.AnyOf do {:error, errors} -> cast_any_of( - %Cast{new_ctx | errors: new_ctx.errors ++ errors}, + %{new_ctx | errors: new_ctx.errors ++ errors}, [schema | failed_schemas], acc ) diff --git a/lib/open_api_spex/cast/one_of.ex b/lib/open_api_spex/cast/one_of.ex index 9fa37b53..fc4fdac8 100644 --- a/lib/open_api_spex/cast/one_of.ex +++ b/lib/open_api_spex/cast/one_of.ex @@ -8,7 +8,7 @@ defmodule OpenApiSpex.Cast.OneOf do error(ctx, [], []) end - def cast(%{schema: %{type: _, oneOf: schemas}} = ctx) do + def cast(%Cast{schema: %{type: _, oneOf: schemas}} = ctx) do castable_schemas = Enum.reduce(schemas, {ctx, [], []}, fn schema, {ctx, results, error_schemas} -> schema = OpenApiSpex.resolve_schema(schema, ctx.schemas) @@ -19,7 +19,7 @@ defmodule OpenApiSpex.Cast.OneOf do {ctx, [{:ok, value, schema} | results], error_schemas} else {:error, errors} -> - {%Cast{ctx | errors: ctx.errors ++ errors}, results, [schema | error_schemas]} + {%{ctx | errors: ctx.errors ++ errors}, results, [schema | error_schemas]} end end)