Class: SoberSwag::Reporting::Output::Described

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

Overview

Add a description onto an object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#view, #views

Methods included from Interface

#call!, #described, #enum, #in_range, #list, #nilable, #partitioned, #referenced, #reporting?, #serialize, #via_map

Constructor Details

#initialize(output, description) ⇒ Described

Returns a new instance of Described.



7
8
9
10
# File 'lib/sober_swag/reporting/output/described.rb', line 7

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

Instance Attribute Details

#descriptionString (readonly)

Returns description of output.

Returns:

  • (String)

    description of output



18
19
20
# File 'lib/sober_swag/reporting/output/described.rb', line 18

def description
  @description
end

#outputInterface (readonly)

Returns output to describe.

Returns:



14
15
16
# File 'lib/sober_swag/reporting/output/described.rb', line 14

def output
  @output
end

Instance Method Details

#call(value) ⇒ Object



20
21
22
# File 'lib/sober_swag/reporting/output/described.rb', line 20

def call(value)
  output.call(value)
end

#serialize_report(value) ⇒ Object



24
25
26
# File 'lib/sober_swag/reporting/output/described.rb', line 24

def serialize_report(value)
  output.serialize_report(value)
end

#swagger_schemaObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/sober_swag/reporting/output/described.rb', line 28

def swagger_schema
  schema, found = output.swagger_schema

  merged =
    if schema.key?(:$ref)
      { allOf: [schema] }
    else
      schema
    end.merge(description: description)
  [merged, found]
end