Class: OasParser::Definition
- Inherits:
-
Object
- Object
- OasParser::Definition
show all
- Includes:
- RawAccessor
- Defined in:
- lib/oas_parser/definition.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
included, #method_missing, #respond_to_missing?
Constructor Details
#initialize(raw, path) ⇒ Definition
Returns a new instance of Definition.
16
17
18
19
|
# File 'lib/oas_parser/definition.rb', line 16
def initialize(raw, path)
@raw = raw
@path = path
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class OasParser::RawAccessor
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
7
8
9
|
# File 'lib/oas_parser/definition.rb', line 7
def path
@path
end
|
#raw ⇒ Object
Returns the value of attribute raw.
9
10
11
|
# File 'lib/oas_parser/definition.rb', line 9
def raw
@raw
end
|
Class Method Details
.resolve(path) ⇒ Object
11
12
13
14
|
# File 'lib/oas_parser/definition.rb', line 11
def self.resolve(path)
raw = Parser.resolve(path)
Definition.new(raw, path)
end
|
Instance Method Details
#endpoints ⇒ Object
47
48
49
|
# File 'lib/oas_parser/definition.rb', line 47
def endpoints
paths.flat_map(&:endpoints)
end
|
21
22
23
|
# File 'lib/oas_parser/definition.rb', line 21
def format
File.extname(@path).sub('.', '')
end
|
#path_by_path(path) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# 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 ⇒ Object
25
26
27
28
29
|
# 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 ⇒ Object
43
44
45
|
# File 'lib/oas_parser/definition.rb', line 43
def security
raw['security'] || []
end
|