Class: GrapeOAS::ApiModel::Path
- Defined in:
- lib/grape_oas/api_model/path.rb
Overview
Represents an API path (endpoint) in the DTO model for OpenAPI v2/v3. Contains a list of operations (HTTP methods) for the path. Used to build the ‘paths’ object in both OpenAPIv2 and OpenAPIv3 documents.
Constant Summary
Constants inherited from Node
Instance Attribute Summary collapse
-
#operations ⇒ Object
Returns the value of attribute operations.
-
#template ⇒ Object
Returns the value of attribute template.
Attributes inherited from Node
Instance Method Summary collapse
- #[](method_sym) ⇒ Object
- #add_operation(operation) ⇒ Object
-
#initialize(template:) ⇒ Path
constructor
A new instance of Path.
Methods inherited from Node
Constructor Details
#initialize(template:) ⇒ Path
Returns a new instance of Path.
14 15 16 17 18 |
# File 'lib/grape_oas/api_model/path.rb', line 14 def initialize(template:) super() @template = template @operations = [] end |
Instance Attribute Details
#operations ⇒ Object
Returns the value of attribute operations.
12 13 14 |
# File 'lib/grape_oas/api_model/path.rb', line 12 def operations @operations end |
#template ⇒ Object
Returns the value of attribute template.
12 13 14 |
# File 'lib/grape_oas/api_model/path.rb', line 12 def template @template end |
Instance Method Details
#[](method_sym) ⇒ Object
24 25 26 |
# File 'lib/grape_oas/api_model/path.rb', line 24 def [](method_sym) @operations.find { |op| op.http_method.to_sym == method_sym.to_sym } end |
#add_operation(operation) ⇒ Object
20 21 22 |
# File 'lib/grape_oas/api_model/path.rb', line 20 def add_operation(operation) @operations << operation end |