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

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

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