   defp update_id(%{id: a} = map, b),
     do: Map.put(map, :id, Utils.update_uri(a, b))
 
-  defp put_ref(map, %Ref{uri: uri}, module) when not is_nil(uri) do
-    case get_schema(uri, module) do
+  defp put_ref(map, %Ref{uri: uri} = ref, module) when not is_nil(uri) do
+    case get_schema(ref, module) do
       nil ->
         map
 


  defp put_ref(map, _, _), do: map

  defp get_schema(uri, module) do
    case remote?(uri) do
      false ->
        nil

      true ->
        case resolve(uri) do
          {:ok, nil} ->
            nil


  defp resolve(uri),
    do: Application.get_env(:xema, :resolver, NoResolver).fetch(uri)

  defp remote?(%Ref{uri: %URI{path: nil}}), do: false

  defp remote?(%Ref{uri: %URI{path: path}, pointer: pointer}),
    do:
      Regex.match?(~r/(\.[a-zA-Z]+)|\#$/, path) or
        String.ends_with?(pointer, "#")

  @spec reduce(Schema.t(), any, function) :: any
  defp reduce(schema, acc, fun) do
