Class: Swagger::Blocks::Nodes::PathNode

Inherits:
Swagger::Blocks::Node show all
Defined in:
lib/swagger/blocks/nodes/path_node.rb

Overview

Constant Summary collapse

OPERATION_TYPES =
[:get, :put, :post, :delete, :options, :head, :patch].freeze

Instance Attribute Summary

Attributes inherited from Swagger::Blocks::Node

#name, #version

Instance Method Summary collapse

Methods inherited from Swagger::Blocks::Node

#as_json, call, #data, #is_swagger_2_0?, #key, #keys

Instance Method Details

#operation(op, inline_keys = nil, &block) ⇒ Object

TODO support ^x- Vendor Extensions

Raises:

  • (ArgumentError)

9
10
11
12
13
# File 'lib/swagger/blocks/nodes/path_node.rb', line 9

def operation(op, inline_keys = nil, &block)
  op = op.to_sym
  raise ArgumentError.new("#{name} not in #{OPERATION_TYPES}") if !OPERATION_TYPES.include?(op)
  self.data[op] = Swagger::Blocks::Nodes::OperationNode.call(version: version, inline_keys: inline_keys, &block)
end

#parameter(inline_keys = nil, &block) ⇒ Object


15
16
17
18
19
20
# File 'lib/swagger/blocks/nodes/path_node.rb', line 15

def parameter(inline_keys = nil, &block)
  inline_keys = {'$ref' => "#/parameters/#{inline_keys}"} if inline_keys.is_a?(Symbol)

  self.data[:parameters] ||= []
  self.data[:parameters] << Swagger::Blocks::Nodes::ParameterNode.call(version: version, inline_keys: inline_keys, &block)
end