analytics/lib/plausible_web/plugins/api/spec.ex
hq1 99efb93082
No longer require domain to seek Plugins API Tokens (#3409)
* No longer require domain to seek Plugins API Tokens

* Accept raw token only
2023-10-16 13:22:09 +02:00

47 lines
1.3 KiB
Elixir

defmodule PlausibleWeb.Plugins.API.Spec do
@moduledoc """
OpenAPI specification for the Plugins API
"""
alias OpenApiSpex.{Components, Info, OpenApi, Paths, Server}
alias PlausibleWeb.Plugins.API.Router
@behaviour OpenApi
@impl OpenApi
def spec do
%OpenApi{
servers: [
%Server{
description: "This server",
url: to_string(PlausibleWeb.Plugins.API.base_uri()),
variables: %{}
}
],
info: %Info{
title: "Plausible Plugins API",
version: "1.0-rc"
},
# Populate the paths from a phoenix router
paths: Paths.from_router(Router),
components: %Components{
securitySchemes: %{
"basic_auth" => %OpenApiSpex.SecurityScheme{
type: "http",
scheme: "basic",
description: """
HTTP basic access authentication using your Site Domain as the
username and the Plugins API Token contents as the password.
Note that Site Domain is optional, a password alone suffices.
For more information see
https://en.wikipedia.org/wiki/Basic_access_authentication
"""
}
}
},
security: [%{"basic_auth" => []}]
}
# Discover request/response schemas from path specs
|> OpenApiSpex.resolve_schema_modules()
end
end