open_api_parser 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27e4d239b851d27954c371b482dd7135aa608845
4
- data.tar.gz: 2bb315c4b4f96d05c8dda30dfb037f2687f02626
3
+ metadata.gz: 673e2c745f8c364512a0c67529c03aec5d32f985
4
+ data.tar.gz: 7e542ca36c68a487d51639af6912a83f56a140d1
5
5
  SHA512:
6
- metadata.gz: bc269a69e72466314e300a146692520d2790c71a18b108f7d1ebcbfa9b61a9ff9ca08769111c2e56217fb62d8feeab17dfe9ab6ed556c0a6cb117252ad665300
7
- data.tar.gz: 76f331f7fde717fa3e5d7be02c5cfa87d735d371d392eecbe8b037ec78f37fa249bf07e2049eae24ff15833ef4bf7a59aeafbb5529d3ffaacbbe8ca8f36f8327
6
+ metadata.gz: c13fb008fe910d5146dab2ada1639352684e5dfb8355c7ee2253346005a61dd72ab87fca76ea5bc59a83bfbe5751dfc940ca8fb591c3eb6853a7a7db712f778c
7
+ data.tar.gz: a6126e71e75fd7b330c19e2e0c48b9c3415d91cb58206ea2af24119d591d640390c02fa26dc2f91c60b1b2fde35d65ab23870d7883f641b950126adeacc6d328
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.2
4
+
5
+ * Match path to correct endpoint when many similar paths exist
6
+
3
7
  ## 1.1.1
4
8
 
5
9
  * Handle invalid URLs in `endpoint`
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Braintree, a division of PayPal, Inc.
3
+ Copyright (c) 2017 Braintree, a division of PayPal, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -11,19 +11,19 @@ module OpenApiParser
11
11
  uri = URI.parse(path)
12
12
  requested_path = uri.path.gsub(/\..+\z/, "")
13
13
 
14
- path_details = @raw["paths"].detect do |path_name, path|
15
- requested_path =~ to_pattern(path_name)
14
+ matching_path_details = @raw["paths"].detect do |path_name, path|
15
+ requested_path =~ to_pattern(path_name) &&
16
+ path.keys.any? { |method| matching_method?(method, request_method) }
16
17
  end
17
- return nil if path_details.nil?
18
+ return nil if matching_path_details.nil?
18
19
 
19
- path = path_details.last
20
+ matching_name, matching_path = matching_path_details
20
21
 
21
- method_details = path.detect do |method, schema|
22
- method.to_s == request_method.downcase
22
+ method_details = matching_path.detect do |method, schema|
23
+ matching_method?(method, request_method)
23
24
  end
24
- return nil if method_details.nil?
25
25
 
26
- Endpoint.new(path_details.first, method_details.first, method_details.last)
26
+ Endpoint.new(matching_name, method_details.first, method_details.last)
27
27
  rescue URI::InvalidURIError
28
28
  nil
29
29
  end
@@ -34,6 +34,10 @@ module OpenApiParser
34
34
 
35
35
  private
36
36
 
37
+ def matching_method?(method, request_method)
38
+ method.to_s == request_method.downcase
39
+ end
40
+
37
41
  def to_pattern(path_name)
38
42
  Regexp.new("\\A" + path_name.gsub(/\{[^}]+\}/, "[^/]+") + "\\z")
39
43
  end
@@ -1,3 +1,3 @@
1
1
  module OpenApiParser
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_api_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-09 00:00:00.000000000 Z
11
+ date: 2017-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_schema