Class: Swagger::Blocks::PathNode

Inherits:
Node
  • Object
show all
Defined in:
lib/swagger/blocks.rb

Overview

Constant Summary collapse

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

Instance Attribute Summary

Attributes inherited from Node

#name, #version

Instance Method Summary collapse

Methods inherited from Node

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

Instance Method Details

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

TODO support ^x- Vendor Extensions

Raises:

  • (ArgumentError)


497
498
499
500
501
# File 'lib/swagger/blocks.rb', line 497

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::OperationNode.call(version: version, inline_keys: inline_keys, &block)
end

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



503
504
505
506
# File 'lib/swagger/blocks.rb', line 503

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