Class: Openapi2ruby::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi2ruby/parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Parser

Returns a new instance of Parser.



12
13
14
# File 'lib/openapi2ruby/parser.rb', line 12

def initialize(path)
  @path = path
end

Class Method Details

.parse(path) ⇒ Openapi2ruby::Openapi

Parse openapi.yaml

Parameters:

  • path (String)

    OpenAPI schema file path

Returns:



8
9
10
# File 'lib/openapi2ruby/parser.rb', line 8

def self.parse(path)
  new(path).parse
end

Instance Method Details

#parseOpenapi2ruby::Openapi

Parse openapi.yaml



18
19
20
# File 'lib/openapi2ruby/parser.rb', line 18

def parse
  Openapi.new(parse_file)
end

#parse_fileObject



22
23
24
25
# File 'lib/openapi2ruby/parser.rb', line 22

def parse_file
  file = File.read(@path)
  YAML.load(file)
end