Class: OasRails::Builders::PathItemBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/oas_rails/builders/path_item_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(specification) ⇒ PathItemBuilder

Returns a new instance of PathItemBuilder.



4
5
6
7
# File 'lib/oas_rails/builders/path_item_builder.rb', line 4

def initialize(specification)
  @specification = specification
  @path_item = Spec::PathItem.new(specification)
end

Instance Method Details

#buildObject



19
20
21
# File 'lib/oas_rails/builders/path_item_builder.rb', line 19

def build
  @path_item
end

#from_path(path, route_extractor: Extractors::RouteExtractor) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/oas_rails/builders/path_item_builder.rb', line 9

def from_path(path, route_extractor: Extractors::RouteExtractor)
  route_extractor.host_routes_by_path(path).each do |oas_route|
    oas_route.verb.downcase.split("|").each do |v|
      @path_item.add_operation(v, OperationBuilder.new(@specification).from_oas_route(oas_route).build)
    end
  end

  self
end