PhoenixSpec.Compiler (PhoenixSpec v0.1.1)

View Source

Mix compiler that automatically regenerates OpenAPI specs when source files change.

Setup

Add to your mix.exs:

def project do
  [
    compilers: Mix.compilers() ++ [:phoenix_spec],
    # ...
  ]
end

Configuration

Configure in config/dev.exs:

config :phoenix_spec,
  router: MyAppWeb.Router,
  output: "priv/static/openapi.json",
  format: "json",
  title: "My API",
  version: "1.0.0"

Or with multiple outputs:

config :phoenix_spec,
  router: MyAppWeb.Router,
  outputs: [
    {"priv/static/openapi.json", "json"},
    {"priv/static/api.d.ts", "ts"}
  ]