View Source OpenApiSpex.Plug.RenderSpec (open_api_spex v3.21.2)

Renders the API spec as a JSON response.

The API spec must be stored in the conn by OpenApiSpex.Plug.PutApiSpec earlier in the plug pipeline.

Example

defmodule MyAppWeb.Router do
  use Phoenix.Router
  alias MyAppWeb.UserController

  pipeline :api do
    plug :accepts, ["json"]
    plug OpenApiSpex.Plug.PutApiSpec, module: MyAppWeb.ApiSpec
  end

  scope "/api" do
    pipe_through :api
    resources "/users", UserController, only: [:create, :index, :show]
    get "/openapi", OpenApiSpex.Plug.RenderSpec, []
  end
end