Class: Jsapi::DSL::Response

Inherits:
Schema show all
Includes:
Examples
Defined in:
lib/jsapi/dsl/response.rb

Overview

Used to specify details of a response.

Instance Method Summary collapse

Methods included from Examples

#example

Methods inherited from Schema

#all_of, #example, #format, #items, #model, #property

Methods inherited from Node

#initialize, #method_missing, #respond_to_missing?

Constructor Details

This class inherits a constructor from Jsapi::DSL::Node

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Jsapi::DSL::Node

Instance Method Details

Defines a link or refers a reusable link object.

# define a link
link 'foo', operation_id: 'bar'

# refer a reusable link
link ref: 'foo'

Refers the reusable link object with the same name if neither any keywords nor a block is specified.

link 'foo'


22
23
24
25
26
27
28
29
30
# File 'lib/jsapi/dsl/response.rb', line 22

def link(name = nil, **keywords, &block)
  _define('link', name&.inspect) do
    name = keywords[:ref] if name.nil?
    keywords = { ref: name } unless keywords.any? || block

    link_model = _meta_model.add_link(name, keywords)
    Node.new(link_model, &block) if block
  end
end