xerions / phoenix_swagger

Swagger integration to Phoenix framework
Mozilla Public License 2.0
691 stars 181 forks source link

No more output from `phx.swagger.generate` after upgrading to 0.8.1 #210

Open phtrivier opened 5 years ago

phtrivier commented 5 years ago

I have an umbrella project where one of the applications is a phoenix project. I updated the version of phoenix_swagger in the phx app from ~> 0.7 to ~> 0.8. This downloaded version 0.8.1, after which I have two issues:

warning: please add the following dependency to your mix.exs:

    {:plug_cowboy, "~> 1.0"}

This dependency is required by Plug.Adapters.Cowboy
which you may be using directly or indirectly.
Note you no longer need to depend on :cowboy directly.
Compiling 203 files (.ex)
** (MatchError) no match of right hand side value: {:error, :bad_directory}
    (mix) lib/mix/compilers/elixir.ex:168: Mix.Compilers.Elixir.compile_manifest/9
    (mix) lib/mix/task.ex:316: Mix.Task.run_task/3
    lib/mix/tasks/swagger.generate.ex:31: Mix.Tasks.Phx.Swagger.Generate.run/1
    (mix) lib/mix/task.ex:316: Mix.Task.run_task/3
    (mix) lib/mix/cli.ex:79: Mix.CLI.run_task/2
** (RuntimeError) Swagger Private build failed
    mix.exs:96: Sitecc.Mixfile.shell_or_fail/2
    mix.exs:103: Sitecc.Mixfile.swagger_build/1
    (mix) lib/mix/task.ex:355: Mix.Task.run_alias/3
    (mix) lib/mix/task.ex:279: Mix.Task.run/2
    (mix) lib/mix/cli.ex:79: Mix.CLI.run_task/2

I can imagine it's pretty localized to my project, and mix is not exactly deterministic, so it might have broken my install beyond repair.

However, no amount of rm -rf _builds && rm -rf deps && mix deps.get && mix deps.compile && mix please.please.please.do.something (which is my highly scientific elixir-compliant way of "working") seems to do the trick.

So any idea how I could attack the problem, would help.

I'm sticking to 0.7.0 in the meantime.

Thanks !

mbuhot commented 5 years ago

Which versions of plug, phoenix and elixir are you on? I’ll try to reproduce this issue.

phtrivier commented 5 years ago

I'm using phoenix 1.34 and plug 1.6.4. That being said, I would not be surprised if it was somehow linked to one of my swagger definitions, but the lack of logs make it hard to check...

aristotelesbr commented 5 years ago

I have the same problem...

Resolving Hex dependencies... Dependency resolution completed: Unchanged: .... phoenix 1.3.4 _phoenix_ecto 3.6.0 phoenix_html 2.12.0 phoenix_live_reload 1.1.7 phoenixpubsub 1.1.1 plug 1.7.1 ...

beno commented 5 years ago

My problems seem to be even worse, I have basically the same umbrella setup, I have to use 0.7 to get any kind of feedback, and when I can get it to work by explicitly adding the -r and -e options all I ever get is an empty file:

{
  "swagger": "2.0",
  "paths": {},
  "info": {
    "version": "1.0",
    "title": "My API"
  },
  "host": "localhost:4000",
  "definitions": {}
}

I am on Phoenix 1.4.0, plug 1.7.1, plug_cowboy 2.0.1

Edit: I looks like you need to add swagger_definitions functions to the controllers to get any kind of output? That is not clear from the docs.

Edit2: hmm, I still don't see any paths in my swagger.json...

Edit 3: oh you need swagger_path macros?

shijithkjayan commented 5 years ago

I too had the same issue followed this medium article to implement swagger. Except that I used the latest version of PhoenixSwagger, and the swagger.json file is not being generated.

My other dependency versions are as follows, phoenix - 1.3.3, phoenix_ecto - 3.2 phoenix_html 2.10 phoenix_pubsub - 1.0

Then I downgraded PhoenixSwagger to 0.6.2 and now it works fine.

mbuhot commented 5 years ago

@shijithkjayan did you add the required configuration?, added in version 0.8:

https://github.com/xerions/phoenix_swagger/blob/master/CHANGELOG.md#080

djthread commented 5 years ago

I think this issue might be touching on the one I just submitted, #237.

I have no paths ("paths":{}) in my umbrella app.

leeduckgo commented 4 years ago

same problem now