class Swagger::Template::Tasks::Reader

Public Class Methods

new(path) click to toggle source
# File lib/swagger/template/tasks/reader.rb, line 8
def initialize(path)
  @path = path
end

Public Instance Methods

read() click to toggle source

Reads out the required info from the provided path

# File lib/swagger/template/tasks/reader.rb, line 13
def read
  specs = read_swagger_specs(@path)
  endpoints = extract_endpoints(specs)
  # enrich_all(endpoints)
end

Private Instance Methods

extract_endpoints(specs) click to toggle source

Extract every path from the endpoints, generating a list of endpoints and related data

# File lib/swagger/template/tasks/reader.rb, line 23
def extract_endpoints(specs)
  specs.map do |spec|
    spec['paths'].keys.map do |path|
      spec['paths'][path].keys.map do |verb|
        Swagger::Template::Endpoint.new(spec, path, verb)
      end
    end
  end.flatten
end
read_swagger_specs(path) click to toggle source

Reads the Swagger specs from the path

# File lib/swagger/template/tasks/reader.rb, line 34
def read_swagger_specs(path)
  Dir["#{path}/**/*.json"].map do |filename|
    JSON.parse(File.read(filename))
  end
end