class OasParser::Definition
Attributes
path[R]
raw[RW]
Public Class Methods
new(raw, path)
click to toggle source
# File lib/oas_parser/definition.rb, line 16 def initialize(raw, path) @raw = raw @path = path end
resolve(path)
click to toggle source
# File lib/oas_parser/definition.rb, line 11 def self.resolve(path) raw = Parser.resolve(path) Definition.new(raw, path) end
Public Instance Methods
endpoints()
click to toggle source
# File lib/oas_parser/definition.rb, line 51 def endpoints paths.flat_map(&:endpoints) end
format()
click to toggle source
# File lib/oas_parser/definition.rb, line 21 def format File.extname(@path).sub('.', '') end
path_by_path(path)
click to toggle source
# File lib/oas_parser/definition.rb, line 31 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
paths()
click to toggle source
# File lib/oas_parser/definition.rb, line 25 def paths raw['paths'].map do |path, definition| OasParser::Path.new(self, path, definition) end end
security()
click to toggle source
# File lib/oas_parser/definition.rb, line 43 def security raw['security'] || [] end
webhooks()
click to toggle source
# File lib/oas_parser/definition.rb, line 55 def webhooks return [] unless raw['webhooks'] raw['webhooks'].map do |name, definition| OasParser::Webhook.new(self, name, definition) end end