Module: RSpec::Rails::Swagger::Helpers::Paths

Defined in:
lib/rspec/rails/swagger/helpers.rb

Instance Method Summary collapse

Instance Method Details

#path(template, attributes = {}, &block) ⇒ Object

Raises:

  • (ArgumentError)


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rspec/rails/swagger/helpers.rb', line 41

def path template, attributes = {}, &block
  attributes.symbolize_keys!

  raise ArgumentError, "Path must start with a /" unless template.starts_with?('/')
  #TODO template might be a $ref
  meta = {
    swagger_object: :path_item,
    swagger_doc: attributes[:swagger_doc] || default_document,
    swagger_path_item: {path: template},
  }
  # Merge tags passed into the path with those from parent contexts.
  if attributes[:tags]
    meta[:tags] = (.try(:[], :tags) || []) + attributes[:tags]
  end
  describe(template, meta, &block)
end