Class: SoberSwag::Reporting::Input::Format

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

Overview

Specify that something must match a particular format. Note: said format is just a string.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Interface

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

Constructor Details

#initialize(input, format) ⇒ Format

Returns a new instance of Format.



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

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

Instance Attribute Details

#formatString (readonly)

Returns:

  • (String)


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

def format
  @format
end

#inputInterface (readonly)

Returns:



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

def input
  @input
end

Instance Method Details

#call(object) ⇒ Object



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

def call(object)
  input.call(object)
end

#swagger_schemaObject



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

def swagger_schema
  schema, found = input.swagger_schema

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