From 9ceb7091532799c33e88cf84f7a1fe4d32408c5b Mon Sep 17 00:00:00 2001 From: Marcel van Pinxteren Date: Tue, 15 Aug 2017 12:00:04 +0200 Subject: [PATCH 1/2] Phoenix 1.3, date format according to Ecto 2.x --- README.md | 3 +++ lib/mix/tasks/swagger.ex | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ce76a3..8fdd075 100644 --- a/README.md +++ b/README.md @@ -174,6 +174,9 @@ The conversion uses schema fields and updates them into schemas unde the [Defini * :boolean -> %{"type" => "boolean"} * :string -> %{"type" => "string"} * :binary -> %{"type" => "string", "format" => "binary"} +* :naive_datetime -> %{"type" => "string", "format" => "date-time"} +* :date -> %{"type" => "string", "format" => "date"} +* :time -> %{"type" => "string", "format" => "date-time"} * :Ecto.DateTime -> %{"type" => "string", "format" => "date-time"} * :Ecto.Date -> %{"type" => "string", "format" => "date"} * :Ecto.Time -> %{"type" => "string", "format" => "date-time"} diff --git a/lib/mix/tasks/swagger.ex b/lib/mix/tasks/swagger.ex index 28a7b2e..78b9e19 100644 --- a/lib/mix/tasks/swagger.ex +++ b/lib/mix/tasks/swagger.ex @@ -112,7 +112,7 @@ defmodule Mix.Tasks.Swagger do cond do args != nil && length(args) > 0 -> Module.concat("Elixir", Enum.at(args, 0)) Mix.Project.umbrella? -> Mix.raise "Umbrella applications require an explicit router to be given to Phoenix.routes" - true -> Module.concat(Mix.Phoenix.base(), "Router") + true -> Module.concat(Mix.Phoenix.base(), "Web.Router") end end @@ -274,6 +274,9 @@ defmodule Mix.Tasks.Swagger do :boolean -> %{"type" => "boolean"} :string -> %{"type" => "string"} :binary -> %{"type" => "string", "format" => "binary"} + :naive_datetime -> %{"type" => "string", "format" => "date-time"} + :date -> %{"type" => "string", "format" => "date"} + :time -> %{"type" => "string", "format" => "date-time"} Ecto.DateTime -> %{"type" => "string", "format" => "date-time"} Ecto.Date -> %{"type" => "string", "format" => "date"} Ecto.Time -> %{"type" => "string", "format" => "date-time"} From 67f2fc341e17c051cfc044733059181badcaa732 Mon Sep 17 00:00:00 2001 From: Marcel van Pinxteren Date: Tue, 3 Oct 2017 11:51:54 +0200 Subject: [PATCH 2/2] Align with Phoenix 1.3 app structure Routes are now found at MyAppWeb.Router. --- lib/mix/tasks/swagger.ex | 10 +++++++--- mix.exs | 8 ++++---- mix.lock | 22 +++++++++++----------- test/mix/tasks/swagger_test.exs | 4 ++-- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/lib/mix/tasks/swagger.ex b/lib/mix/tasks/swagger.ex index 78b9e19..4f17841 100644 --- a/lib/mix/tasks/swagger.ex +++ b/lib/mix/tasks/swagger.ex @@ -110,9 +110,13 @@ defmodule Mix.Tasks.Swagger do @spec get_router([any]) :: term def get_router(args) do cond do - args != nil && length(args) > 0 -> Module.concat("Elixir", Enum.at(args, 0)) - Mix.Project.umbrella? -> Mix.raise "Umbrella applications require an explicit router to be given to Phoenix.routes" - true -> Module.concat(Mix.Phoenix.base(), "Web.Router") + args != nil && length(args) > 0 -> + Module.concat("Elixir", Enum.at(args, 0)) + Mix.Project.umbrella? -> + Mix.raise "Umbrella applications require an explicit router to be given to Phoenix.routes" + true -> + Keyword.get(Mix.Phoenix.inflect(""), :web_module) + |> Module.concat("Router") end end diff --git a/mix.exs b/mix.exs index 0cb84f7..c720caa 100644 --- a/mix.exs +++ b/mix.exs @@ -7,7 +7,7 @@ defmodule SwaggerDoc.Mixfile do [ app: :swaggerdoc, version: @version, - elixir: "~> 1.0", + elixir: "~> 1.4", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, deps: deps(), @@ -43,12 +43,12 @@ defmodule SwaggerDoc.Mixfile do # Type `mix help deps` for more examples and options defp deps do [ - {:phoenix, "~> 1.2"}, - {:ecto, "~> 2.0"}, + {:phoenix, "~> 1.3"}, + {:ecto, "~> 2.1"}, {:poison, "~> 2.0"}, {:ex_doc, "~> 0.8.4", only: :docs}, {:earmark, "~> 0.1.17", only: :docs}, - {:meck, "~> 0.8.3", only: :test}, + {:meck, "~> 0.8.4", only: :test}, ] end diff --git a/mix.lock b/mix.lock index a48aee0..a56860f 100644 --- a/mix.lock +++ b/mix.lock @@ -1,11 +1,11 @@ -%{"decimal": {:hex, :decimal, "1.2.0", "462960fd71af282e570f7b477f6be56bf8968e68277d4d0b641a635269bf4b0d", [:mix], []}, - "earmark": {:hex, :earmark, "0.1.17", "a2269e72ff85501bdb58c2de9edc0a9a17a4be2757883eed1f601b30494ed2bf", [:mix], []}, - "ecto": {:hex, :ecto, "2.0.5", "7f4c79ac41ffba1a4c032b69d7045489f0069c256de606523c65d9f8188e502d", [:mix], [{:db_connection, "~> 1.0-rc.4", [hex: :db_connection, optional: true]}, {:decimal, "~> 1.1.2 or ~> 1.2", [hex: :decimal, optional: false]}, {:mariaex, "~> 0.7.7", [hex: :mariaex, optional: true]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: false]}, {:postgrex, "~> 0.12.0", [hex: :postgrex, optional: true]}, {:sbroker, "~> 1.0-beta", [hex: :sbroker, optional: true]}]}, - "ex_doc": {:hex, :ex_doc, "0.8.4", "c74a30b09627ff22a2bb7f75d3b75dec3aedb2bd434bb3009a73a40425c2315d", [:mix], [{:earmark, "~> 0.1.17 or ~> 0.2", [hex: :earmark, optional: true]}]}, - "meck": {:hex, :meck, "0.8.3", "4628a1334c69610c5bd558b04dc78d723d8ec5445c123856de34c77f462b5ee5", [:rebar], []}, - "mime": {:hex, :mime, "1.0.1", "05c393850524767d13a53627df71beeebb016205eb43bfbd92d14d24ec7a1b51", [:mix], []}, - "phoenix": {:hex, :phoenix, "1.2.1", "6dc592249ab73c67575769765b66ad164ad25d83defa3492dc6ae269bd2a68ab", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, optional: false]}, {:plug, "~> 1.1", [hex: :plug, optional: false]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: false]}]}, - "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.1", "c10ddf6237007c804bf2b8f3c4d5b99009b42eca3a0dfac04ea2d8001186056a", [:mix], []}, - "plug": {:hex, :plug, "1.2.2", "cfbda521b54c92ab8ddffb173fbaabed8d8fc94bec07cd9bb58a84c1c501b0bd", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}, {:mime, "~> 1.0", [hex: :mime, optional: false]}]}, - "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []}, - "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []}} +%{"decimal": {:hex, :decimal, "1.4.0", "fac965ce71a46aab53d3a6ce45662806bdd708a4a95a65cde8a12eb0124a1333", [:mix], []}, + "earmark": {:hex, :earmark, "0.1.19", "ffec54f520a11b711532c23d8a52b75a74c09697062d10613fa2dbdf8a9db36e", [:mix], []}, + "ecto": {:hex, :ecto, "2.1.6", "29b45f393c2ecd99f83e418ea9b0a2af6078ecb30f401481abac8a473c490f84", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, optional: true]}]}, + "ex_doc": {:hex, :ex_doc, "0.8.4", "c74a30b09627ff22a2bb7f75d3b75dec3aedb2bd434bb3009a73a40425c2315d", [], [{:earmark, "~> 0.1.17 or ~> 0.2", [hex: :earmark, optional: true]}]}, + "meck": {:hex, :meck, "0.8.7", "ebad16ca23f685b07aed3bc011efff65fbaf28881a8adf925428ef5472d390ee", [:rebar3], []}, + "mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], []}, + "phoenix": {:hex, :phoenix, "1.3.0", "1c01124caa1b4a7af46f2050ff11b267baa3edb441b45dbf243e979cd4c5891b", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, optional: false]}, {:plug, "~> 1.3.3 or ~> 1.4", [hex: :plug, optional: false]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, optional: false]}]}, + "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.2", "bfa7fd52788b5eaa09cb51ff9fcad1d9edfeb68251add458523f839392f034c1", [:mix], []}, + "plug": {:hex, :plug, "1.4.3", "236d77ce7bf3e3a2668dc0d32a9b6f1f9b1f05361019946aae49874904be4aed", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, optional: true]}, {:mime, "~> 1.0", [hex: :mime, optional: false]}]}, + "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [], []}, + "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [], []}} diff --git a/test/mix/tasks/swagger_test.exs b/test/mix/tasks/swagger_test.exs index 46c0cd1..517b38d 100644 --- a/test/mix/tasks/swagger_test.exs +++ b/test/mix/tasks/swagger_test.exs @@ -152,11 +152,11 @@ defmodule Mix.Tasks.Swagger.Tests do # get_router tests test "get_router - nil args" do - assert Swagger.get_router(nil) == Swaggerdoc.Router + assert Swagger.get_router(nil) == SwaggerdocWeb.Router end test "get_router - empty args" do - assert Swagger.get_router([]) == Swaggerdoc.Router + assert Swagger.get_router([]) == SwaggerdocWeb.Router end #==============================