Swagger error

I’m getting a swagger error which looks something like this

Generated wizex app
** (UndefinedFunctionError) function Poison.encode!/2 is undefined (module Poison is not available)
    Poison.encode!(%{definitions: %{}, host: "localhost:4000", info: %{title: "wizex", version: "1.0"}, paths: %{}, swagger: "2.0"}, [pretty: true])
    lib/mix/tasks/swagger.generate.ex:55: anonymous fn/1 in Mix.Tasks.Phx.Swagger.Generate.run/1
    (elixir 1.10.2) lib/enum.ex:789: anonymous fn/3 in Enum.each/2
    (stdlib 3.12) maps.erl:232: :maps.fold_1/3
    (elixir 1.10.2) lib/enum.ex:2127: Enum.each/2
    (mix 1.10.2) lib/mix/task.ex:330: Mix.Task.run_task/3
    (mix 1.10.2) lib/mix/cli.ex:82: Mix.CLI.run_task/2
    (elixir 1.10.2) lib/code.ex:917: Code.require_file/2

I have looked into issues created by other developers. That suggest we should do this

  1. add {:jason, "~> 1.0"}, to your mix.exs deps
  2. add config :phoenix, :json_library, Jason to your config/config.exs

But I have done that but still getting the error

Can anyone suggest?

Do I have to add a Poison for this?

First of all, you should specify which library you are using for Swagger, otherwise it’s hard to help. I assume you are using this one.

If that’s correct, its documentation says this:

Also you can configure json library to use:

config :phoenix_swagger, json_library: Jason

Which is different from the configuration you posted above.

1 Like

Sorry for that

def deps do
    {:phoenix_swagger, "~> 0.8"},
    {:ex_json_schema, "~> 0.5"} # optional

I’m using this

But I got your point. Let me check