       _ -> responses
     end    
   end
+
+  def build_definitions([], def_json), do: def_json
+  def build_definitions([code_def | remaining_defs], def_json) do
+    module = elem(code_def, 0)
+    if :erlang.function_exported(module, :__info__, 1) && Keyword.has_key?(module.__info__(:functions), :__schema__) do
+      properties_json = Enum.reduce module.__schema__(:types), %{}, fn(type, properties_json) ->
+        property_name = elem(type, 0)
+
+        # Need to map Ecto types (https://github.com/elixir-lang/ecto/blob/v1.0.0/lib/ecto/schema.ex#L107-L145)
+        # to Swagger types (http://swagger.io/specification/#dataTypeType)
+        property_type = case elem(type, 1) do
+          :id -> %{"type" => "integer", "format" => "int64"}
+          :binary_id -> %{"type" => "string", "format" => "binary"}
+          :integer -> %{"type" => "integer", "format" => "int64"}
+          :float -> %{"type" => "number", "format" => "float"}
+          :boolean -> %{"type" => "boolean"}
+          :string -> %{"type" => "string"}
+          :binary -> %{"type" => "string", "format" => "binary"}
+          :Ecto.DateTime -> %{"type" => "string", "format" => "date-time"}
+          :Ecto.Date -> %{"type" => "string", "format" => "date"}
+          :Ecto.Time -> %{"type" => "string", "format" => "date-time"}
+          :uuid -> %{"type" => "string"}
+          _ -> %{"type" => "string"}
+        end
+        
+        Map.put(properties_json, "#{property_name}", property_type)
+      end
+
+      module_json = %{"properties" => properties_json}
+      def_json = Map.put(def_json, "#{inspect module}", module_json)
+    end
+
+    build_definitions(remaining_defs, def_json)
+  end
 end

  def run(args) do
    Mix.shell.info "Generating Swagger documentation..."
    router = get_router(args)
    json = build_swagger_response(router)

    output_path = System.cwd!() <> "/swagger"
    File.mkdir_p!(output_path)
    File.write!("#{output_path}/api.json", Poison.encode!(json))
    Mix.shell.info "Finished generating Swagger documentation!"
  end


        Module.concat(Mix.Phoenix.base(), "Router")
    end
  end  

  def add_routes(nil, swagger), do: swagger
  def add_routes([], swagger), do: swagger
