Class: OpenApiAnnotator::PathsBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/open_api_annotator/paths_builder.rb

Instance Method Summary collapse

Instance Method Details

#buildObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/open_api_annotator/paths_builder.rb', line 3

def build
  paths = OpenApi::Paths.new
  routes = RoutesFinder.new.find_all
  path_regexp = OpenApiAnnotator.config.path_regexp
  if path_regexp
    routes.select! { |route| route.path.match(path_regexp) }
  end
  routes.group_by(&:path).each do |path_name, routes|
    paths[path_name] = build_path_item(routes)
    puts "Path '#{path_name}' has been created."
  end

  paths
end