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 +4 -4
- data/lib/openapi_contracts/doc/parser.rb +12 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f218118990cd1c4d1d2933bcb42a84a84492226a1a075d2cb92a5acd026b3478
|
4
|
+
data.tar.gz: 072bf7fd56d4a22adacb31706e8773888588e3e466b9783653065a335de4a063
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|