Rolodex v0.10.1 Rolodex.Router

Macros for defining API routes that Rolodex should document. Functions for serializing these routes into fully formed docs metadata.

A Rolodex Router is the entry point when Rolodex is compiling your docs. You provide the router with two things:

1) A Phoenix Router 2) A list of API paths (HTTP action + full URI path)

Rolodex then looks up the controller action function associated with each API path, collects the doc annotations for each, and serializes it all to your docs output of choice.

Example

defmodule MyRolodexRouter do
  use Rolodex.Router

  alias MyWebApp.PhoenixRouter

  router PhoenixRouter do
    # Can use macros that pair with HTTP actions, just like in Phoenix
    get "/api/users"
    post "/api/users"
    put "/api/users/:id"
    patch "/api/users/:id"
    delete "/api/users/:id"
    head "/api/users/:id"
    options "/api/users/:id"

    # Our can use the more verbose route/2 macro
    route :get, "/api/users"

    # Use routes/2 to define multiple routes that use the same path
    routes [:put, :patch, :delete], "/api/users/:id"
  end
end

Link to this section Summary

Functions

Collects all the routes defined in a Rolodex.Router into a list of fully serialized Rolodex.Route structs

Defines an HTTP DELETE route at the given path to document

Defines an HTTP GET route at the given path to document

Defines an HTTP HEAD route at the given path to document

Defines an HTTP OPTIONS route at the given path to document

Defines an HTTP PATCH route at the given path to document

Defines an HTTP POST route at the given path to document

Defines an HTTP PUT route at the given path to document

Defines a route with the given HTTP action verb and path to document

Opens up a definition for a Rolodex router. Used to define which routes Rolodex should document

Defines a set of routes with different HTTP action verbs at the same path to document

Link to this section Functions

Link to this function

build_routes(router_mod, config)
build_routes(module(), Rolodex.Config.t()) :: [Rolodex.Route.t()]

Collects all the routes defined in a Rolodex.Router into a list of fully serialized Rolodex.Route structs.

Link to this macro

delete(path) (macro)

Defines an HTTP DELETE route at the given path to document

delete "/api/entity/:id"
Link to this macro

get(path) (macro)

Defines an HTTP GET route at the given path to document

get "/api/entity/:id"
Link to this macro

head(path) (macro)

Defines an HTTP HEAD route at the given path to document

head "/api/entity/:id"
Link to this macro

options(path) (macro)

Defines an HTTP OPTIONS route at the given path to document

options "/api/entity/:id"
Link to this macro

patch(path) (macro)

Defines an HTTP PATCH route at the given path to document

patch "/api/entity/:id"
Link to this macro

post(path) (macro)

Defines an HTTP POST route at the given path to document

post "/api/entity"
Link to this macro

put(path) (macro)

Defines an HTTP PUT route at the given path to document

put "/api/entity/:id"
Link to this macro

route(verb, path) (macro)

Defines a route with the given HTTP action verb and path to document

route :get, "/api/entity/:id"
Link to this macro

router(phoenix_router, list) (macro)

Opens up a definition for a Rolodex router. Used to define which routes Rolodex should document.

router MyApp.MyPhoenixRouter do
  get "/api/health"

  get "/api/users"
  post "/api/users"
  put "/api/users/:id"
end
Link to this macro

routes(verbs, path) (macro)

Defines a set of routes with different HTTP action verbs at the same path to document

routes [:get, :put, :delete], "/api/entity/:id"