Serve SwaggerUI from a Plug/Phoenix application.
The package can be installed by adding swagger_ui_plug
to your list of dependencies in mix.exs
:
def deps do
[
{:swagger_ui_plug, "~> 1.0"}
]
end
Add a route for SwaggerUI.Plug
with the path to your OpenAPI spec, and any additional options.
scope "/api" do
...
get "/swaggerui", SwaggerUi.Plug,
path: "/api/openapi",
default_model_expand_depth: 3,
display_operation_id: true
end
See the full docs at https://hexdocs.pm/swagger_ui_plug.
Thanks to the original contributors to OpenApiSpex.Plug.SwaggerUI
@mbuhot, @zorbash, @jonathanhood, @moxley, @m0rt3nlund, @reneweteling, @superhawk610