openapi_contracts 0.4.0 → 0.4.1

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: '099e0e1cdfaf7938e46ba4bdcdbad4d6627d9065a5af46eb757290b27d3faed8'
4
- data.tar.gz: a49babd20945272751b9609fa09ddcd7b0da35824aff3de586b059c9d465cba2
3
+ metadata.gz: f218118990cd1c4d1d2933bcb42a84a84492226a1a075d2cb92a5acd026b3478
4
+ data.tar.gz: 072bf7fd56d4a22adacb31706e8773888588e3e466b9783653065a335de4a063
5
5
  SHA512:
6
- metadata.gz: 192fc72178785d45bb029bd9fdd2f1a8af8f33409957375e582701f539d6e8a38715856eabda776904e9acb6d4a36b330f4872a7db1b3f335daeb456299b41f8
7
- data.tar.gz: 978184d22801606c97d24926a941b5b6d61bdf08d786417df0246cd7ff5ed8321572d60554060ec0c8575ca73f56aa41784d441e154bb9b0d1064f125f9df7d6
6
+ metadata.gz: 54e760ebff2c63b357bad2f47b1ad741405fbe23997af447079361e377cda3419d7befa4717cc193e0f7f11fe56ce719dc93c3dc198e70b9257b30b3d8e3e1db
7
+ data.tar.gz: b706d606ec874409f5b1cdae4dd3b166b036cbc009f4d288f423cfae870c4db8d58e5751ebc38607e7b1349b189c4441bb78256d349a9739653966c7490b751c
@@ -20,7 +20,7 @@ module OpenapiContracts
20
20
 
21
21
  def parse_file(path, translate: true)
22
22
  schema = YAML.safe_load(File.read(path))
23
- translate ? translate_paths(schema, Pathname(path).parent) : schema
23
+ translate ? translate_paths!(schema, Pathname(path).parent) : schema
24
24
  end
25
25
 
26
26
  def join_partials(cwd, data)
@@ -67,14 +67,17 @@ module OpenapiContracts
67
67
  data
68
68
  end
69
69
 
70
- def translate_paths(data, cwd)
71
- data.each_with_object({}) do |(key, val), m|
72
- if val.is_a?(Hash)
73
- m[key] = translate_paths(val, cwd)
74
- elsif key == '$ref' && val !~ %r{^#/}
75
- m[key] = json_pointer(cwd.join(val), '#/')
76
- else
77
- m[key] = val
70
+ def translate_paths!(data, cwd)
71
+ case data
72
+ when Array
73
+ data.each { |v| translate_paths!(v, cwd) }
74
+ when Hash
75
+ data.each_pair do |k, v|
76
+ if k == '$ref' && v !~ %r{^#/}
77
+ v.replace json_pointer(cwd.join(v), '#/')
78
+ else
79
+ translate_paths!(v, cwd)
80
+ end
78
81
  end
79
82
  end
80
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_contracts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mkon