PhoenixSwagger v0.8.0 Release Notes

Release Date: 2018-03-13 // almost 2 years ago
    • Passing module names and output path as mix task parameters is no longer supported.
    • Inferring default module names from mix project is no longer supported.
    • Swagger file outputs, router module and optional endpoint module must now be specified in application config:
      config :my_app, :phoenix_swagger,
        swagger_files: %{
          "priv/static/swagger.json" => [router: MyAppWeb.Router, endpoint: MyAppWeb.Endpoint],
          # additional swagger files here
        }
    
    • phoenix_swagger can now be run as a mix compiler task, ensuring that the generated swagger is kept in sync with code, and enabling live reloading.
      compilers: [:phoenix, :gettext, :phoenix_swagger] ++ Mix.compilers
    
    • The HTTP verb and path can now be inferred from the phoenix router:
      swagger_path :show do
        get "/api/users/{id}
        description "Gets a user by ID"
        response 200, "OK", Schema.ref(User)
      end
    

    Can now be written without the get:

      swagger_path :show do
        description "Gets a user by ID"
        response 200, "OK", Schema.ref(User)
      end
    

    Note that if your controller contains a delete/2 function (such as when using the resources convention), then calling delete/2 from PhoenixSwagger.Path will now cause a compilation error. To avoid this problem, include the full module (shown below), or simply remove the line and allow the verb and path to be inferred from the route:

      swagger_path(:delete) do
        PhoenixSwagger.Path.delete "/api/users/{id}"
        summary "Delete User"
      end