Class: Jsapi::Meta::Callback::Model

Inherits:
Base::Model show all
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

Methods inherited from Base::Model

#initialize, #inspect, #merge!, #reference?, #resolve

Methods included from Base::Attributes

#attribute, #attribute_names

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.

Raises:

  • (ArgumentError)


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

#operationsObject

: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