Class: OpenAPIParser::PathItemFinder
- Inherits:
-
Object
- Object
- OpenAPIParser::PathItemFinder
- Defined in:
- lib/openapi_parser/path_item_finder.rb
Defined Under Namespace
Instance Method Summary collapse
-
#initialize(paths) ⇒ PathItemFinder
constructor
A new instance of PathItemFinder.
-
#operation_object(http_method, request_path) ⇒ Result?
find operation object and if not exist return nil.
Constructor Details
#initialize(paths) ⇒ PathItemFinder
Returns a new instance of PathItemFinder.
3 4 5 6 7 8 |
# File 'lib/openapi_parser/path_item_finder.rb', line 3 def initialize(paths) @root = PathNode.new('/') @paths = paths @paths.path.each { |path, _path_item_object| @root.register_path_node(path.split('/'), path) } end |
Instance Method Details
#operation_object(http_method, request_path) ⇒ Result?
find operation object and if not exist return nil
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/openapi_parser/path_item_finder.rb', line 14 def operation_object(http_method, request_path) if (path_item_object = @paths.path[request_path]) if (op = path_item_object.operation(http_method)) return Result.new(path_item_object, op, request_path, {}) # find no path_params path end end # check with path_params parse_request_path(http_method, request_path) end |