Class: Openapi2ruby::Cli

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

Instance Method Summary collapse

Instance Method Details

#generate(path) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/openapi2ruby/cli.rb', line 17

def generate(path)
  puts 'Loading OpenAPI yaml file...'
  raise "File not found. #{path}" unless File.exist?(path)

  openapi = Openapi2ruby::Parser.parse(path)
  openapi.schemas.each do |schema|
    serializer = Openapi2ruby::Generator.generate(schema, options[:out], options[:template])
    puts "Created: #{serializer}"
  end
end

#parse(path) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/openapi2ruby/cli.rb', line 6

def parse(path)
  puts 'Loading OpenAPI yaml file...'
  raise "File not found. #{path}" unless File.exist?(path)

  openapi = Openapi2ruby::Parser.parse(path)
  p openapi.schemas
end