oas_parser 0.15.2 → 0.16.0

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
  SHA256:
3
- metadata.gz: 69856fb6b9f6d1fe397f91a1089781129c53034618bca01119e238324350f0c5
4
- data.tar.gz: d49a50d9b06b3ea31d89dc693cd6a359e24cc75c01786f74dd44ddad263a2b5f
3
+ metadata.gz: 37e97626c43f146f01f818554db72c53c9aeb7d80adfdfeb030e64ed1c23bdff
4
+ data.tar.gz: c5b84aabd9f633dedc50b9fcafc394f62585e7922bae8530f244582c375b5059
5
5
  SHA512:
6
- metadata.gz: 3bd4584baa8eca3d9477c9845174fa203978717f00e60e9818894b03bb5ccfd2d97e034c42828b5d7e97cb55c0b16ada5ad424be7f7a8e51a330593e364133a2
7
- data.tar.gz: fa3fd17b559c36b373a949c79b4c23fe34fb6a37901014570a377a54fbf4e0d2bc8db8cf2bc89b2b95b43cef05fc3e07acb450deb33e9c91528af105145f5199
6
+ metadata.gz: 16bcbfdf167076235e13b3d01a34796d7e0a67306dea7c10490ebe20a737e5e57f422a1853a680fb7346b93b402c7128c2b32461d99ad379c09e988a3e631ac8
7
+ data.tar.gz: a6b26fcb02a9751e7019f10ad05bd20735dd0ba71aa631db63eb1376310c7fc05b1d8c925390317177cad797823ae7b6d05c0a6490022f1e4e36e0f68a41268b
data/.gitignore CHANGED
@@ -10,3 +10,5 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
+ .ruby-gemset
14
+ .ruby-version
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oas_parser (0.15.2)
5
- activesupport (> 5.1.2, < 6)
4
+ oas_parser (0.16.0)
5
+ activesupport (>= 4.0.0)
6
6
  addressable (~> 2.3)
7
7
  builder (~> 3.2.3)
8
8
  deep_merge (~> 1.2.1)
9
9
  mustermann-contrib (~> 1.0.3s)
10
- nokogiri (~> 1.8.1)
10
+ nokogiri
11
11
 
12
12
  GEM
13
13
  remote: https://rubygems.org/
@@ -17,11 +17,11 @@ GEM
17
17
  i18n (>= 0.7, < 2)
18
18
  minitest (~> 5.1)
19
19
  tzinfo (~> 1.1)
20
- addressable (2.5.2)
20
+ addressable (2.6.0)
21
21
  public_suffix (>= 2.0.2, < 4.0)
22
22
  builder (3.2.3)
23
23
  coderay (1.1.2)
24
- concurrent-ruby (1.1.3)
24
+ concurrent-ruby (1.1.4)
25
25
  deep_merge (1.2.1)
26
26
  diff-lcs (1.3)
27
27
  docile (1.1.5)
@@ -42,7 +42,7 @@ GEM
42
42
  guard-compat (~> 1.1)
43
43
  rspec (>= 2.99.0, < 4.0)
44
44
  hansi (0.2.0)
45
- i18n (1.2.0)
45
+ i18n (1.5.3)
46
46
  concurrent-ruby (~> 1.0)
47
47
  json (2.1.0)
48
48
  listen (3.1.5)
@@ -51,15 +51,15 @@ GEM
51
51
  ruby_dep (~> 1.2)
52
52
  lumberjack (1.0.13)
53
53
  method_source (0.9.2)
54
- mini_portile2 (2.3.0)
54
+ mini_portile2 (2.4.0)
55
55
  minitest (5.11.3)
56
56
  mustermann (1.0.3)
57
57
  mustermann-contrib (1.0.3)
58
58
  hansi (~> 0.2.0)
59
59
  mustermann (= 1.0.3)
60
60
  nenv (0.3.0)
61
- nokogiri (1.8.5)
62
- mini_portile2 (~> 2.3.0)
61
+ nokogiri (1.10.1)
62
+ mini_portile2 (~> 2.4.0)
63
63
  notiffany (0.1.1)
64
64
  nenv (~> 0.1)
65
65
  shellany (~> 0.0)
@@ -34,10 +34,12 @@ module OasParser
34
34
  if fragment.is_a?(Hash) && fragment.has_key?("$ref")
35
35
  ref = fragment["$ref"]
36
36
 
37
- if ref =~ /\Afile:/
38
- expand_file(ref)
39
- else
37
+ if ref =~ /^#/
40
38
  expand_pointer(ref)
39
+ elsif ref =~ /^(http(s)?|\/\/)/
40
+ expand_url(ref)
41
+ else
42
+ expand_file(ref)
41
43
  end
42
44
  else
43
45
  fragment
@@ -45,17 +47,34 @@ module OasParser
45
47
  end
46
48
 
47
49
  def expand_file(ref)
48
- relative_path = ref.split(":").last
49
- absolute_path = File.expand_path(File.join("..", relative_path), @path)
50
+ absolute_path = File.expand_path(File.join("..", ref), @path)
51
+ absolute_path, local_reference = absolute_path.split('#')
52
+ if local_reference
53
+ # skip first item in the split array, it is blank
54
+ local_reference_path = local_reference.split('/')[1..-1]
55
+ resolved_remote_reference = Parser.resolve(absolute_path)
50
56
 
51
- Parser.resolve(absolute_path)
57
+ # expand the pointer included as part of the remote reference
58
+ # within the context of the remote reference
59
+ expanded_pointer = expand_pointer('#' + local_reference, resolved_remote_reference)
60
+
61
+ # extract the local reference data from the remote remote reference
62
+ # and include the expanded pointer
63
+ resolved_remote_reference.dig(*local_reference_path).merge(expanded_pointer)
64
+ else
65
+ Parser.resolve(absolute_path)
66
+ end
52
67
  end
53
68
 
54
- def expand_pointer(ref)
69
+ def expand_pointer(ref, content=nil)
55
70
  pointer = OasParser::Pointer.new(ref)
56
- fragment = pointer.resolve(@content)
71
+ fragment = pointer.resolve(content || @content)
57
72
 
58
73
  expand_refs(fragment)
59
74
  end
75
+
76
+ def expand_url(ref)
77
+ raise 'Expanding URL References is not supported'
78
+ end
60
79
  end
61
80
  end
@@ -1,3 +1,3 @@
1
1
  module OasParser
2
- VERSION = '0.15.2'.freeze
2
+ VERSION = '0.16.0'.freeze
3
3
  end
data/oas_parser.gemspec CHANGED
@@ -22,10 +22,10 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_dependency "addressable", "~> 2.3"
24
24
  spec.add_dependency "deep_merge", "~> 1.2.1"
25
- spec.add_dependency "activesupport", "> 5.1.2", "< 6"
25
+ spec.add_dependency "activesupport", ">= 4.0.0"
26
26
  spec.add_dependency "builder", "~> 3.2.3"
27
27
  spec.add_dependency "mustermann-contrib", "~> 1.0.3s"
28
- spec.add_dependency "nokogiri", "~> 1.8.1"
28
+ spec.add_dependency "nokogiri"
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 1.16"
31
31
  spec.add_development_dependency "guard-rspec", "~> 4.7.3"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oas_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Butler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-05 00:00:00.000000000 Z
11
+ date: 2019-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -42,22 +42,16 @@ dependencies:
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 5.1.2
48
- - - "<"
49
- - !ruby/object:Gem::Version
50
- version: '6'
47
+ version: 4.0.0
51
48
  type: :runtime
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
- - - ">"
56
- - !ruby/object:Gem::Version
57
- version: 5.1.2
58
- - - "<"
52
+ - - ">="
59
53
  - !ruby/object:Gem::Version
60
- version: '6'
54
+ version: 4.0.0
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: builder
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -90,16 +84,16 @@ dependencies:
90
84
  name: nokogiri
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
- - - "~>"
87
+ - - ">="
94
88
  - !ruby/object:Gem::Version
95
- version: 1.8.1
89
+ version: '0'
96
90
  type: :runtime
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
- - - "~>"
94
+ - - ">="
101
95
  - !ruby/object:Gem::Version
102
- version: 1.8.1
96
+ version: '0'
103
97
  - !ruby/object:Gem::Dependency
104
98
  name: bundler
105
99
  requirement: !ruby/object:Gem::Requirement