Class: SoberSwag::Reporting::Input::Referenced

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

Overview

An input that should be "referenced" in the final schema.

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

Returns a new instance of Referenced.



7
8
9
10
# File 'lib/sober_swag/reporting/input/referenced.rb', line 7

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

Instance Attribute Details

#referenceString (readonly)

Returns key in the components hash.

Returns:

  • (String)

    key in the components hash



17
18
19
# File 'lib/sober_swag/reporting/input/referenced.rb', line 17

def reference
  @reference
end

#valueInterface (readonly)

Returns the actual input.

Returns:



14
15
16
# File 'lib/sober_swag/reporting/input/referenced.rb', line 14

def value
  @value
end

Instance Method Details

#call(input) ⇒ Object



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

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

#ref_pathObject (private)



32
33
34
# File 'lib/sober_swag/reporting/input/referenced.rb', line 32

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

#swagger_schemaObject



23
24
25
26
27
28
# File 'lib/sober_swag/reporting/input/referenced.rb', line 23

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