Sha256: 03a99f36693bfaba59f273366d01095dd9c88fe00de2126d2bf72cc4cf23e5a1
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
require 'mustermann/template' module OasParser class Definition include OasParser::RawAccessor raw_keys :info, :servers, :components, :openapi attr_reader :path attr_accessor :raw def self.resolve(path) raw = Parser.resolve(path) Definition.new(raw, path) end def initialize(raw, path) @raw = raw @path = path end def format File.extname(@path).sub('.', '') 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] return OasParser::Path.new(self, path, definition) if definition key = raw['paths'].keys.detect do |path_entry| Mustermann::Template.new(path_entry).match(path) end definition = raw['paths'][key] raise OasParser::PathNotFound.new("Path not found: '#{path}'") unless definition OasParser::Path.new(self, key, definition) end def security raw['security'] || [] end def endpoints paths.flat_map(&:endpoints) end def webhooks return [] unless raw['webhooks'] raw['webhooks'].map do |name, definition| OasParser::Webhook.new(self, name, definition) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
oas_parser-0.25.1 | lib/oas_parser/definition.rb |
oas_parser-0.25.0 | lib/oas_parser/definition.rb |