Class: SoberSwag::Reporting::Input::Described

Inherits:
Base
  • Object
show all
Defined in:
lib/sober_swag/reporting/input/described.rb

Overview

Node for things with descriptions. This describes the type, not the object key.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Interface

#add_schema_key, #call!, #described, #enum, #format, #in_range, #list, #mapped, #modify_schema, #multiple_of, #optional, #or, #referenced, #swagger_path_schema, #swagger_query_schema, #|

Constructor Details

#initialize(input, description) ⇒ Described

Returns a new instance of Described.



8
9
10
11
# File 'lib/sober_swag/reporting/input/described.rb', line 8

def initialize(input, description)
  @input = input
  @description = description
end

Instance Attribute Details

#descriptionString (readonly)

Returns description of input.

Returns:

  • (String)

    description of input



19
20
21
# File 'lib/sober_swag/reporting/input/described.rb', line 19

def description
  @description
end

#inputInterface (readonly)

Returns base input.

Returns:



15
16
17
# File 'lib/sober_swag/reporting/input/described.rb', line 15

def input
  @input
end

Instance Method Details

#call(value) ⇒ Object



21
22
23
# File 'lib/sober_swag/reporting/input/described.rb', line 21

def call(value)
  input.call(value)
end

#swagger_schemaObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/sober_swag/reporting/input/described.rb', line 25

def swagger_schema
  val, other = input.swagger_schema
  merged =
    if val.key?(:$ref)
      { allOf: [val] }
    else
      val
    end.merge(description: description)
  [merged, other]
end