ScalarPlug

ScalarPlug is an Elixir plug to integrate Scalar into your Elixir application. When a request URL path matches the path the plug has been configured with, it returns a HTML response initializing Scalar.

Installation

The package is available in Hex and you can install it by adding the dependency to your project’s mix.exs:

def deps do
  [
    {:scalar_plug, "~> 0.1.0"}
  ]
end

Usage

You can add ScalarPlug as a plug to your project passing the configuration options as a keyword list, or a mfa {:module, :function} to fetch the options at runtime. The following options are supported:

Compile-time configuration

plug ScalarPlug, path: "/api/docs", spec_path: "/api/spec", title: "API Documentation"

MFA runtime configuration

plug ScalarPlug, {ConfigurationModule, :scalar_config}

Function runtime configuration

plug ScalarPlug, fn -> [path: "/api/docs", spec_path: "/api/spec", title: "API Documentation"] end