Class: OpenapiParameters::Path
- Inherits:
-
Object
- Object
- OpenapiParameters::Path
- Defined in:
- lib/openapi_parameters/path.rb
Overview
Parses OpenAPI path parameters from a route params Hash that is usually provided by your Rack webframework
Instance Attribute Summary collapse
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
Instance Method Summary collapse
-
#initialize(parameters, convert: true) ⇒ Path
constructor
A new instance of Path.
- #unpack(path_params) ⇒ Object
Constructor Details
Instance Attribute Details
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
15 16 17 |
# File 'lib/openapi_parameters/path.rb', line 15 def parameters @parameters end |
Instance Method Details
#unpack(path_params) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/openapi_parameters/path.rb', line 18 def unpack(path_params) parameters.each_with_object({}) do |parameter, result| next unless path_params.key?(parameter.name) result[parameter.name] = catch :skip do value = Unpacker.unpack_value(parameter, path_params[parameter.name]) @convert ? Converter.convert(value, parameter.schema) : value end end end |