Class: Jsapi::Meta::Callback::Base
- Inherits:
-
Model::Base
- Object
- Model::Base
- Jsapi::Meta::Callback::Base
- Defined in:
- lib/jsapi/meta/callback/base.rb
Overview
Specifies a callback. Applies to OpenAPI 3.0 and higher.
Constant Summary
Constants included from Model::Attributes
Model::Attributes::DEFAULT_ARRAY, Model::Attributes::DEFAULT_HASH
Instance Method Summary collapse
-
#add_operation(expression, keywords = {}) ⇒ Object
Adds a callback operation.
-
#operations ⇒ Object
:attr: operations.
-
#to_openapi(version, definitions) ⇒ Object
Returns a hash representing the OpenAPI callback object.
Methods inherited from Model::Base
#initialize, #inspect, #merge!, #reference?, #resolve
Methods included from Model::Attributes
Constructor Details
This class inherits a constructor from Jsapi::Meta::Model::Base
Instance Method Details
#add_operation(expression, keywords = {}) ⇒ Object
Adds a callback operation.
Raises an ArgumentError if expression is blank.
17 18 19 20 21 |
# File 'lib/jsapi/meta/callback/base.rb', line 17 def add_operation(expression, keywords = {}) raise ArgumentError, "expression can't be blank" if expression.blank? (@operations ||= {})[expression.to_s] = Operation.new(nil, keywords) end |
#operations ⇒ Object
:attr: operations
12 |
# File 'lib/jsapi/meta/callback/base.rb', line 12 attribute :operations, { String => Operation }, accessors: i[reader writer] |
#to_openapi(version, definitions) ⇒ Object
Returns a hash representing the OpenAPI callback object.
24 25 26 27 28 |
# File 'lib/jsapi/meta/callback/base.rb', line 24 def to_openapi(version, definitions) operations.transform_values do |operation| OpenAPI::PathItem.new([operation]).to_openapi(version, definitions) end end |