View Source Swagdox.Endpoint (swagdox v0.2.0)

Describes a documented endpoint in an application controller.

Summary

Functions

Extracts function docs that contain Open API specifications. A function doc is considered to contain an Open API specification if it contains the string "[Swagdox] API:", followed by one or more lines that start with @-variables.

Returns the parameters for the endpoint.

Returns the responses for the endpoint.

Returns the authorization options for the endpoint.

Returns the list of tags for the endpoint

Types

@type docstring() :: String.t()
@type t() :: %Swagdox.Endpoint{
  docstring: docstring(),
  function: atom(),
  module: module()
}

Functions

@spec extract_all(module()) :: {:ok, [t()]} | {:error, String.t()}

Extracts function docs that contain Open API specifications. A function doc is considered to contain an Open API specification if it contains the string "[Swagdox] API:", followed by one or more lines that start with @-variables.

An example of a function doc that contains an Open API specification:

Returns a User.

[Swagdox] API:
  @param id, integer, required, "User ID"

  @response 200, User, "User found"
  @response 403, "User not authorized"
  @response 404, "User not found"
@spec parameters(t()) :: [Swagdox.Parameter.t()]

Returns the parameters for the endpoint.

@spec responses(t()) :: [Swagdox.Response.t()]

Returns the responses for the endpoint.

@spec security(t()) :: [String.t()]

Returns the authorization options for the endpoint.

@spec tags(t()) :: [String.t()]

Returns the list of tags for the endpoint