Class: Nexmo::OAS::Renderer::OpenApiDefinitionResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb

Class Method Summary collapse

Class Method Details

.find(name) ⇒ Object

Raises:

  • (Errno::ENOENT)


9
10
11
12
13
14
15
16
17
# File 'lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb', line 9

def self.find(name)
  path = paths(name).detect do |p|
    break p if File.file? p
  end

  return resolve(path) if path

  raise Errno::ENOENT, "Could not find definition '#{name}' in '#{API.oas_path}'"
end

.path(name, format) ⇒ Object



25
26
27
# File 'lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb', line 25

def self.path(name, format)
  "#{API.oas_path}/#{name}.#{format}"
end

.paths(name) ⇒ Object



19
20
21
22
23
# File 'lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb', line 19

def self.paths(name)
  %w[json yaml yml].map do |format|
    path(name, format)
  end
end

.resolve(path) ⇒ Object



29
30
31
# File 'lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb', line 29

def self.resolve(path)
  OasParser::Definition.resolve(path)
end