Class: SoberSwag::Reporting::Output::Referenced

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

Overview

Referenced: An input that will be referred to via reference in the final schema.

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, reference) ⇒ Referenced

Returns a new instance of Referenced.



8
9
10
11
# File 'lib/sober_swag/reporting/output/referenced.rb', line 8

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

Instance Attribute Details

#outputInterface (readonly)

Returns the actual output type to use.

Returns:

  • (Interface)

    the actual output type to use



15
16
17
# File 'lib/sober_swag/reporting/output/referenced.rb', line 15

def output
  @output
end

#referenceString (readonly)

Returns key in the components hash.

Returns:

  • (String)

    key in the components hash



19
20
21
# File 'lib/sober_swag/reporting/output/referenced.rb', line 19

def reference
  @reference
end

Instance Method Details

#call(input) ⇒ Object



21
22
23
# File 'lib/sober_swag/reporting/output/referenced.rb', line 21

def call(input)
  output.call(input)
end

#ref_pathObject



29
30
31
# File 'lib/sober_swag/reporting/output/referenced.rb', line 29

def ref_path
  "#/components/schemas/#{reference}"
end

#serialize_report(input) ⇒ Object



25
26
27
# File 'lib/sober_swag/reporting/output/referenced.rb', line 25

def serialize_report(input)
  output.serialize_report(input)
end

#swagger_schemaObject



33
34
35
36
37
38
# File 'lib/sober_swag/reporting/output/referenced.rb', line 33

def swagger_schema
  [
    { "$ref": ref_path },
    { reference => proc { output.swagger_schema } }
  ]
end