Class: Jsapi::Meta::Callback::Model
- Inherits:
-
Base::Model
- Object
- Base::Model
- Jsapi::Meta::Callback::Model
- Defined in:
- lib/jsapi/meta/callback/model.rb
Overview
Specifies a callback object. Applies to OpenAPI 3.0 and higher.
Constant Summary
Constants included from Base::Attributes
Base::Attributes::DEFAULT_ARRAY, Base::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 Base::Model
#initialize, #inspect, #merge!, #reference?, #resolve
Methods included from Base::Attributes
Constructor Details
This class inherits a constructor from Jsapi::Meta::Base::Model
Instance Method Details
#add_operation(expression, keywords = {}) ⇒ Object
Adds a callback operation.
Raises an ArgumentError
if expression
is blank.
19 20 21 22 23 |
# File 'lib/jsapi/meta/callback/model.rb', line 19 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/model.rb', line 12 attribute :operations, { String => Operation } |
#to_openapi(version, definitions) ⇒ Object
Returns a hash representing the OpenAPI callback object.
26 27 28 29 30 |
# File 'lib/jsapi/meta/callback/model.rb', line 26 def to_openapi(version, definitions) operations.transform_values do |operation| { operation.method => operation.to_openapi(version, definitions) } end end |