mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-28 18:18:55 +00:00
Why: * In order to manage a large number of Firezone Sites, Resources, Policies, etc... a REST API is needed as clicking through the UI is too time consuming, as well as prone to error. By providing a REST API Firezone customers will be able to manage things within their Firezone accounts with code.
28 lines
790 B
Elixir
28 lines
790 B
Elixir
defmodule API.ApiSpec do
|
|
alias OpenApiSpex.{Components, Info, OpenApi, Paths, SecurityScheme, Server}
|
|
alias API.{Endpoint, Router}
|
|
@behaviour OpenApi
|
|
|
|
@impl OpenApi
|
|
def spec do
|
|
%OpenApi{
|
|
servers: [
|
|
# Populate the Server info from a phoenix endpoint
|
|
Server.from_endpoint(Endpoint)
|
|
],
|
|
info: %Info{
|
|
title: "Firezone API",
|
|
version: "1.0"
|
|
},
|
|
# Populate the paths from a phoenix router
|
|
paths: Paths.from_router(Router),
|
|
components: %Components{
|
|
securitySchemes: %{"authorization" => %SecurityScheme{type: "http", scheme: "bearer"}}
|
|
},
|
|
security: [%{"authorization" => []}]
|
|
}
|
|
# Discover request/response schemas from path specs
|
|
|> OpenApiSpex.resolve_schema_modules()
|
|
end
|
|
end
|