Class: OpenapiContracts::Doc::Parameter
- Inherits:
-
Object
- Object
- OpenapiContracts::Doc::Parameter
- Defined in:
- lib/openapi_contracts/doc/parameter.rb
Instance Attribute Summary collapse
-
#in ⇒ Object
readonly
Returns the value of attribute in.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #in_path? ⇒ Boolean
-
#initialize(spec) ⇒ Parameter
constructor
A new instance of Parameter.
- #matches?(value) ⇒ Boolean
Constructor Details
#initialize(spec) ⇒ Parameter
Returns a new instance of Parameter.
5 6 7 8 9 10 11 |
# File 'lib/openapi_contracts/doc/parameter.rb', line 5 def initialize(spec) @spec = spec = spec.to_h @name = ['name'] @in = ['in'] @required = ['required'] end |
Instance Attribute Details
#in ⇒ Object (readonly)
Returns the value of attribute in.
3 4 5 |
# File 'lib/openapi_contracts/doc/parameter.rb', line 3 def in @in end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/openapi_contracts/doc/parameter.rb', line 3 def name @name end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
3 4 5 |
# File 'lib/openapi_contracts/doc/parameter.rb', line 3 def schema @schema end |
Instance Method Details
#in_path? ⇒ Boolean
13 14 15 |
# File 'lib/openapi_contracts/doc/parameter.rb', line 13 def in_path? @in == 'path' end |
#matches?(value) ⇒ Boolean
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/openapi_contracts/doc/parameter.rb', line 17 def matches?(value) case @spec.dig('schema', 'type') when 'integer' integer_parameter_matches?(value) when 'number' number_parameter_matches?(value) else schemer.valid?(value) end end |