Module: SoberSwag::Reporting::Input::Interface
Overview
Module for interface methods.
Instance Method Summary collapse
- #add_schema_key(base, addition) ⇒ Object
- #call!(value) ⇒ Object
- #described(desc) ⇒ Object
- #enum(*cases) ⇒ Object
- #format(format) ⇒ Object
-
#in_range(range) ⇒ InRange
Constrained values: must be in range.
-
#list ⇒ List
(also: #array)
A list of this input.
-
#mapped(&block) ⇒ Mapped
Map a function after this input runs.
- #modify_schema(base, addition) ⇒ Object
-
#multiple_of(number) ⇒ Object
Constrained values: must be a multiple of the given number.
-
#optional ⇒ Either
(also: #nilable)
This, or null.
-
#or(other) ⇒ Either
Make a new input that is either this type or the argument.
- #referenced(name) ⇒ Object
- #swagger_path_schema ⇒ Object
- #swagger_query_schema ⇒ Object
- #|(other) ⇒ Object
Instance Method Details
#add_schema_key(base, addition) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 107 def add_schema_key(base, addition) if base.key?(:$ref) { allOf: [base] }.merge(addition) else base.merge(addition) end end |
#call!(value) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 81 def call!(value) res = call(value) raise Report::Error.new(res) if res.is_a?(Report::Base) # rubocop:disable Style/RaiseArgs res end |
#described(desc) ⇒ Object
65 66 67 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 65 def described(desc) Described.new(self, desc) end |
#enum(*cases) ⇒ Object
69 70 71 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 69 def enum(*cases) Enum.new(self, cases) end |
#format(format) ⇒ Object
61 62 63 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 61 def format(format) Format.new(self, format) end |
#in_range(range) ⇒ InRange
Constrained values: must be in range.
45 46 47 48 49 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 45 def in_range(range) raise ArgumentError, "need a range, not a #{range.class}" unless range.is_a?(Range) InRange.new(self, range) end |
#list ⇒ List Also known as: array
A list of this input.
36 37 38 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 36 def list List.new(self) end |
#mapped(&block) ⇒ Mapped
Map a function after this input runs.
77 78 79 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 77 def mapped(&block) Mapped.new(self, block) end |
#modify_schema(base, addition) ⇒ Object
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 96 def modify_schema(base, addition) schema, found = base.swagger_schema merged = if schema.key?(:$ref) { allOf: [schema] } else schema end.merge(addition) [merged, found] end |
#multiple_of(number) ⇒ Object
Constrained values: must be a multiple of the given number
53 54 55 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 53 def multiple_of(number) MultipleOf.new(self, number) end |
#optional ⇒ Either Also known as: nilable
This, or null.
26 27 28 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 26 def optional self | Null.new end |
#or(other) ⇒ Either
Make a new input that is either this type or the argument.
12 13 14 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 12 def or(other) Either.new(self, other) end |
#referenced(name) ⇒ Object
57 58 59 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 57 def referenced(name) Referenced.new(self, name) end |
#swagger_path_schema ⇒ Object
88 89 90 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 88 def swagger_path_schema raise InvalidSchemaError::InvalidForPathError.new(self) # rubocop:disable Style/RaiseArgs end |
#swagger_query_schema ⇒ Object
92 93 94 |
# File 'lib/sober_swag/reporting/input/interface.rb', line 92 def swagger_query_schema raise InvalidSchemaError::InvalidForQueryError.new(self) # rubocop:disable Style/RaiseArgs end |