ScalarPlug

Note: This is a maintained fork of tuist/scalar_plug, originally created by Pedro Piñera and Marek Fořt. The upstream package appears to be unmaintained — open PRs and issues have gone unaddressed for an extended period. This fork exists to keep dependencies up to date and accept community contributions. A PR has been submitted upstream; if it becomes active again, consider switching back.

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_api_plug, "~> 0.3.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_href: "/api/spec", title: "API Documentation"

MFA runtime configuration

plug ScalarPlug, {ConfigurationModule, :scalar_config}

Function runtime configuration

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