PhoenixSwagger.Path (phoenix_swagger v0.8.3) View Source

Defines the swagger path DSL for specifying Controller actions. This module should not be imported directly, it will be automatically imported in the scope of a swagger_path macro body.

Examples

use PhoenixSwagger

swagger_path :index do
  get "/users"
  produces "application/json"
  paging
  parameter :id, :query, :integer, "user id", required: true
  tag "Users"
  response 200 "User resource" :User
  response 404 "User not found"
end

Link to this section Summary

Functions

Adds a mime-type to the consumes list of the operation of a swagger %PathObject{}

Initializes a PathObject with verb "delete" and given path

Adds the deprecation section to the operation of a swagger %PathObject{}

Adds the description section to the operation of a swagger %PathObject{}

Initializes a PathObject with verb "get" and given path

Initializes a PathObject with verb "head" and given path

Converts the %PathObject{} struct into the nested JSON form expected by swagger

Adds the operationId section to the operation of a swagger %PathObject{}

Initializes a PathObject with verb "options" and given path

Adds page size, number and offset parameters to the operation of a swagger %PathObject{}

Adds a parameter to the operation of a swagger %PathObject{}

Defines multiple parameters for an operation with a custom DSL syntax

Initializes a PathObject with verb "patch" and given path

Initializes a PathObject with verb "post" and given path

Adds a mime-type to the produces list of the operation of a swagger %PathObject{}

Initializes a PathObject with verb "put" and given path

Adds a response to the operation of a swagger %PathObject{}, without a schema

Adds a response to the operation of a swagger %PathObject{}, with a schema

Adds the security section to the operation of a swagger %PathObject{}

Adds the summary section to the operation of a swagger %PathObject{}

Adds a tag to the operation of a swagger %PathObject{}

Link to this section Functions

Link to this function

consumes(path, mimetype)

View Source

Adds a mime-type to the consumes list of the operation of a swagger %PathObject{}

Initializes a PathObject with verb "delete" and given path

Link to this function

deprecated(path, status)

View Source

Adds the deprecation section to the operation of a swagger %PathObject{}

Link to this function

description(path, description)

View Source

Adds the description section to the operation of a swagger %PathObject{}

Link to this function

expand_response_example(path_object, opts)

View Source

Initializes a PathObject with verb "get" and given path

Initializes a PathObject with verb "head" and given path

Converts the %PathObject{} struct into the nested JSON form expected by swagger

Adds the operationId section to the operation of a swagger %PathObject{}

Initializes a PathObject with verb "options" and given path

Link to this function

paging(path, opts \\ [size: "page_size", number: "page"])

View Source

Adds page size, number and offset parameters to the operation of a swagger %PathObject{}

The names default to "page_size" and "page" for ease of use with scriviner_ecto, but can be overridden.

Examples

get "/api/pets/"
paging
response 200, "OK"

get "/api/pets/dogs"
paging size: "page_size", number: "count"
response 200, "OK"

get "/api/pets/cats"
paging size: "limit", offset: "offset"
response 200, "OK"
Link to this function

parameter(path, name, location, type, description, opts \\ [])

View Source

Adds a parameter to the operation of a swagger %PathObject{}

Link to this macro

parameters(path, block)

View Source (macro)

Defines multiple parameters for an operation with a custom DSL syntax

Example

swagger_path :create do
  post "/api/v1/{team}/users"
  summary "Create a new user"
  parameters do
    user :body, Schema.ref(:User), "user attributes"
    team :path, :string, "Users team ID"
  end
  response 200, "OK", :User
end

Initializes a PathObject with verb "patch" and given path

Initializes a PathObject with verb "post" and given path

Link to this function

produces(path, mimetype)

View Source

Adds a mime-type to the produces list of the operation of a swagger %PathObject{}

Initializes a PathObject with verb "put" and given path

Link to this function

response(path, status, description)

View Source

Adds a response to the operation of a swagger %PathObject{}, without a schema

Link to this function

response(path, status, description, schema, opts \\ [])

View Source

Adds a response to the operation of a swagger %PathObject{}, with a schema

Optional keyword args can be provided for headers and examples If the mime-type is known from the produces list, then a single can be given as a shorthand.

Example

get "/users/{id}"
produces "application/json"
parameter :id, :path, :integer, "user id", required: true
response 200, "Success", :User, examples: %{"application/json": %{id: 1, name: "Joe"}}

get "/users/{id}"
produces "application/json"
parameter :id, :path, :integer, "user id", required: true
response 200, "Success", :User, example: %{id: 1, name: "Joe"}
Link to this function

security(path, security)

View Source

Adds the security section to the operation of a swagger %PathObject{}

Adds the summary section to the operation of a swagger %PathObject{}

Adds a tag to the operation of a swagger %PathObject{}