Sha256: c30e98e643f89e46b1adc5959bf76965bef7a587e39ad12e06b5aa30abedf6a1

Contents?: true

Size: 716 Bytes

Versions: 4

Compression:

Stored size: 716 Bytes

Contents

require_relative './oas_parser'

module Nexmo
  module OAS
    module Renderer
      class OpenApiDefinitionResolver
        def self.find(name)
          path = paths(name).detect do |p|
            break p if File.file? p
          end

          return resolve(path) if path

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

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nexmo-oas-renderer-0.6.6 lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb
nexmo-oas-renderer-0.6.5 lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb
nexmo-oas-renderer-0.6.4 lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb
nexmo-oas-renderer-0.6.3 lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb