PhoenixSwagger.swagger_path
You're seeing just the macro
swagger_path
, go back to PhoenixSwagger module for more information.
Swagger operations (aka "paths") are defined inside a swagger_path
block.
Within the do-end block, the DSL provided by the PhoenixSwagger.Path
module can be used.
The DSL is any chain of functions with first argument being a PhoenixSwagger.Path.PathObject
struct.
The verb and path can be set explicitly using the get
, put
, post
, patch
, delete
functions, or
inferred from the phoenix router automatically.
Swagger tags
will default to match the module name with trailing Controller
removed.
Eg operations defined in module MyApp.UserController will have tags: ["User"]
.
Swagger operationId
will default to the fully qualified action function name.
Eg index
action in MyApp.UserController
will have operationId: "MyApp.UserController.index"
.
Example
defmodule ExampleController do
use ExampleApp.Web, :controller
use PhoenixSwagger
swagger_path :index do
get "/users"
summary "Get users"
description "Get users, filtering by account ID"
parameter :query, :id, :integer, "account id", required: true
response 200, "Description", :Users
tag "users"
end
def index(conn, _params) do
posts = Repo.all(Post)
render(conn, "index.json", posts: posts)
end
end