Sha256: a639014ac316dfed82d457d2144665c3082c73424030fe5102e3a38bc795e35e

Contents?: true

Size: 742 Bytes

Versions: 15

Compression:

Stored size: 742 Bytes

Contents

module OasParser
  class Definition
    include OasParser::RawAccessor
    raw_keys :info, :servers, :components, :openapi

    attr_accessor :raw

    def self.resolve(path)
      raw = Parser.resolve(path)
      Definition.new(raw)
    end

    def initialize(raw)
      @raw = raw
    end

    def paths
      raw['paths'].map do |path, definition|
        OasParser::Path.new(self, path, definition)
      end
    end

    def path_by_path(path)
      definition = raw['paths'][path]
      raise StandardError.new('So such path exists') unless definition
      OasParser::Path.new(self, path, definition)
    end

    def security
      raw['security'] || []
    end

    def endpoints
      paths.flat_map(&:endpoints)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
oas_parser-0.11.1 lib/oas_parser/definition.rb
oas_parser-0.11.0 lib/oas_parser/definition.rb
oas_parser-0.10.0 lib/oas_parser/definition.rb
oas_parser-0.9.0 lib/oas_parser/definition.rb
oas_parser-0.8.1 lib/oas_parser/definition.rb
oas_parser-0.8.0 lib/oas_parser/definition.rb
oas_parser-0.7.0 lib/oas_parser/definition.rb
oas_parser-0.6.0 lib/oas_parser/definition.rb
oas_parser-0.5.0 lib/oas_parser/definition.rb
oas_parser-0.4.0 lib/oas_parser/definition.rb
oas_parser-0.3.0 lib/oas_parser/definition.rb
oas_parser-0.2.0 lib/oas_parser/definition.rb
oas_parser-0.1.2 lib/oas_parser/definition.rb
oas_parser-0.1.1 lib/oas_parser/definition.rb
oas_parser-0.1.0 lib/oas_parser/definition.rb