       true -> type
       false -> {type, schema(json)}
     end
+    |> IO.inspect(label: :src)
   end
+
+  def to_xema(json) when is_boolean(json), do: json
 
   defp type(map) do
     {type, map} = Map.pop(map, "type", :any)
     {type_to_atom(type), map}
   end
 
+  defp type_to_atom(list) when is_list(list), do: Enum.map(list, &type_to_atom/1)
+
   defp type_to_atom("object"), do: :map
 
-  defp type_to_atom(type), do: String.to_existing_atom(type)
+  defp type_to_atom("array"), do: :list
+
+  defp type_to_atom("null"), do: nil
+
+  defp type_to_atom(type) when is_binary(type), do: String.to_existing_atom(type)
+
+  defp type_to_atom(type), do: type
 
   defp schema(json), do: json |> Enum.map(&rule/1) |> Keyword.new()
 

  Converts a JSON Schema to Xema source.
  """

  alias Xema.Schema

  @type json_schema :: true | false | map

  @spec to_xema(json_schema :: json_schema) :: atom | tuple
  def to_xema(json) when is_map(json) do

    |> rule(value)
  end

  defp rule(:"$ref", value), do: {:ref, value}

  defp rule(:format, value) do
    {:format, value |> ConvCase.to_snake_case() |> String.to_existing_atom()}
  end

  defp rule(key, value) when key in @schema_map do
    {key, Enum.into(value, %{}, fn {key, value} -> {key, to_xema(value)} end)}
  end

  defp rule(key, value) when key in @schemas and is_list(value) do
    {key, Enum.map(value, &to_xema/1)}
  end

  defp rule(key, value) when key in @schema do
    {key, to_xema(value)}
  end

  defp rule(key, value), do: {key, value}
