Class: OasCore::Spec::Paths

Inherits:
Object
  • Object
show all
Includes:
Specable
Defined in:
lib/oas_core/spec/paths.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Specable

#as_json, #oas_fields

Constructor Details

#initialize(specification) ⇒ Paths

Returns a new instance of Paths.



10
11
12
13
# File 'lib/oas_core/spec/paths.rb', line 10

def initialize(specification)
  @specification = specification
  @path_items = {}
end

Instance Attribute Details

#path_itemsObject

Returns the value of attribute path_items.



8
9
10
# File 'lib/oas_core/spec/paths.rb', line 8

def path_items
  @path_items
end

Instance Method Details

#add_path(path, oas_routes) ⇒ Object



15
16
17
# File 'lib/oas_core/spec/paths.rb', line 15

def add_path(path, oas_routes)
  @path_items[path] = Builders::PathItemBuilder.new(@specification).with_oas_routes(oas_routes).build
end

#to_specObject



19
20
21
22
23
24
25
# File 'lib/oas_core/spec/paths.rb', line 19

def to_spec
  paths_hash = {}
  @path_items.each do |path, path_object|
    paths_hash[path] = path_object.to_spec
  end
  paths_hash
end