openapi_contracts 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/openapi_contracts/doc/parser.rb +16 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '099e0e1cdfaf7938e46ba4bdcdbad4d6627d9065a5af46eb757290b27d3faed8'
|
4
|
+
data.tar.gz: a49babd20945272751b9609fa09ddcd7b0da35824aff3de586b059c9d465cba2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 192fc72178785d45bb029bd9fdd2f1a8af8f33409957375e582701f539d6e8a38715856eabda776904e9acb6d4a36b330f4872a7db1b3f335daeb456299b41f8
|
7
|
+
data.tar.gz: 978184d22801606c97d24926a941b5b6d61bdf08d786417df0246cd7ff5ed8321572d60554060ec0c8575ca73f56aa41784d441e154bb9b0d1064f125f9df7d6
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ First parse your api documentation:
|
|
16
16
|
|
17
17
|
```ruby
|
18
18
|
# This must point to the folder where the "openapi.yaml" file is
|
19
|
-
$doc = OpenapiContracts::Doc.parse(Rails.root.join('spec
|
19
|
+
$doc = OpenapiContracts::Doc.parse(Rails.root.join('spec/fixtures/openapi/api-docs/openapi'))
|
20
20
|
```
|
21
21
|
|
22
22
|
Ideally you do this once in a RSpec `before(:suite)` hook.
|
@@ -12,7 +12,8 @@ module OpenapiContracts
|
|
12
12
|
abs_path = @dir.join(path)
|
13
13
|
data = parse_file(abs_path, translate: false)
|
14
14
|
data.deep_merge! merge_components
|
15
|
-
join_partials(abs_path.dirname, data)
|
15
|
+
data = join_partials(abs_path.dirname, data)
|
16
|
+
nullable_to_type!(data)
|
16
17
|
end
|
17
18
|
|
18
19
|
private
|
@@ -34,10 +35,23 @@ module OpenapiContracts
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
38
|
+
def nullable_to_type!(object)
|
39
|
+
case object
|
40
|
+
when Hash
|
41
|
+
if object['type'] && object['nullable']
|
42
|
+
object['type'] = [object['type'], 'null']
|
43
|
+
object.delete 'nullable'
|
44
|
+
else
|
45
|
+
object.each_value { |o| nullable_to_type! o }
|
46
|
+
end
|
47
|
+
when Array
|
48
|
+
object.each { |o| nullable_to_type! o }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
37
52
|
def merge_components
|
38
53
|
data = {}
|
39
54
|
Dir[File.expand_path('components/**/*.yaml', @dir)].each do |file|
|
40
|
-
# pn = Pathname(file).relative_path_from(@dir)
|
41
55
|
pointer = json_pointer(Pathname(file)).split('/')
|
42
56
|
i = 0
|
43
57
|
pointer.reduce(data) do |h, p|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi_contracts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mkon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -78,28 +78,28 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - '='
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 1.29.
|
81
|
+
version: 1.29.1
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - '='
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 1.29.
|
88
|
+
version: 1.29.1
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: rubocop-rspec
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - '='
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: 2.
|
95
|
+
version: 2.11.1
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - '='
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 2.
|
102
|
+
version: 2.11.1
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: simplecov
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '2.7'
|
147
147
|
- - "<"
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: '3.
|
149
|
+
version: '3.3'
|
150
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
151
|
requirements:
|
152
152
|
- - ">="
|