Class: Jsapi::DSL::Response
- Includes:
- Examples
- Defined in:
- lib/jsapi/dsl/response.rb
Overview
Used to define a response.
Instance Method Summary collapse
-
#header(name = nil, **keywords, &block) ⇒ Object
Specifies an HTTP header of the response.
-
#link(name = nil, **keywords, &block) ⇒ Object
Specifies a link.
Methods included from Examples
Methods inherited from Schema
#all_of, #example, #format, #items, #model, #property
Methods inherited from Base
#import, #import_relative, #initialize, #respond_to_missing?
Constructor Details
This class inherits a constructor from Jsapi::DSL::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Jsapi::DSL::Base
Instance Method Details
#header(name = nil, **keywords, &block) ⇒ Object
Specifies an HTTP header of the response.
header 'X-Foo', type: 'string'
Refers a resuable header if the ‘:ref` keyword is specified.
header ref: 'x_foo'
Refers the reusable header with the same name if neither any keywords nor a block is specified.
header 'x_foo'
See Meta::Response::Model#headers for further information.
35 36 37 38 39 40 41 42 43 |
# File 'lib/jsapi/dsl/response.rb', line 35 def header(name = nil, **keywords, &block) define('header', name&.inspect) do name = keywords[:ref] if name.nil? keywords = { ref: name } unless keywords.any? || block header_model = @meta_model.add_header(name, keywords) Base.new(header_model, &block) if block end end |
#link(name = nil, **keywords, &block) ⇒ Object
Specifies a link.
link 'foo', operation_id: 'bar'
Refers a reusable link if the ‘:ref` keyword is specified.
link ref: 'foo'
Refers the reusable link with the same name if neither any keywords nor a block is specified.
link 'foo'
58 59 60 61 62 63 64 65 66 |
# File 'lib/jsapi/dsl/response.rb', line 58 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) Base.new(link_model, &block) if block end end |