zero-rails_openapi 1.5.7 → 1.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +2 -2
- data/Gemfile.lock +37 -37
- data/documentation/parameter.md +1 -0
- data/lib/oas_objs/example_obj.rb +5 -3
- data/lib/oas_objs/media_type_obj.rb +1 -1
- data/lib/oas_objs/schema_obj.rb +12 -9
- data/lib/open_api/dsl.rb +4 -2
- data/lib/open_api/dsl/api.rb +1 -1
- data/lib/open_api/dsl/components.rb +1 -1
- data/lib/open_api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 39f35108e381101fa164cda95f406a2317dac0fd7527fd1a05860301a41633f0
|
4
|
+
data.tar.gz: 949cdb1266842f65c92b8f1822f0c4fe1c2cc6c566bf5164c2b6bee168e29fb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed98743a9c8709cbeca382a61c343b4a93d2f62342a2f35cdf16fba131fa1129906d015b875dd1eca23bacfdcfc306806c5b05a2089a6fc3e016e625dc49e906
|
7
|
+
data.tar.gz: 8a88b1ff4011352b2f5875fbce9615c33cd3da3be6e1b068aacf2e902f36ccac5048862b54c701c79d7bbb5c1199bf2216bae66f091a126afcb78982996b3697
|
data/CHANGELOG.md
CHANGED
@@ -6,11 +6,11 @@
|
|
6
6
|
|
7
7
|
## Changed
|
8
8
|
|
9
|
-
1. issue [#16](
|
9
|
+
1. issue [#16](https://github.com/zhandao/zero-rails_openapi/issues/16) DSL in `base_doc_class` can not be generated.
|
10
10
|
|
11
11
|
## Fixed
|
12
12
|
|
13
|
-
1. issue [#15](
|
13
|
+
1. issue [#15](https://github.com/zhandao/zero-rails_openapi/issues/15) colorize was not required.
|
14
14
|
2. securitySchemes defined by config DSL was not be generated.
|
15
15
|
|
16
16
|
## [1.5.6] - 2018/3/23 - [view diff](https://github.com/zhandao/zero-rails_openapi/compare/v1.5.5...v1.5.6)
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
zero-rails_openapi (1.5.
|
4
|
+
zero-rails_openapi (1.5.8)
|
5
5
|
activesupport (>= 3)
|
6
6
|
colorize
|
7
7
|
rails (>= 3)
|
@@ -9,54 +9,54 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
actioncable (5.1.
|
13
|
-
actionpack (= 5.1.
|
12
|
+
actioncable (5.1.6)
|
13
|
+
actionpack (= 5.1.6)
|
14
14
|
nio4r (~> 2.0)
|
15
15
|
websocket-driver (~> 0.6.1)
|
16
|
-
actionmailer (5.1.
|
17
|
-
actionpack (= 5.1.
|
18
|
-
actionview (= 5.1.
|
19
|
-
activejob (= 5.1.
|
16
|
+
actionmailer (5.1.6)
|
17
|
+
actionpack (= 5.1.6)
|
18
|
+
actionview (= 5.1.6)
|
19
|
+
activejob (= 5.1.6)
|
20
20
|
mail (~> 2.5, >= 2.5.4)
|
21
21
|
rails-dom-testing (~> 2.0)
|
22
|
-
actionpack (5.1.
|
23
|
-
actionview (= 5.1.
|
24
|
-
activesupport (= 5.1.
|
22
|
+
actionpack (5.1.6)
|
23
|
+
actionview (= 5.1.6)
|
24
|
+
activesupport (= 5.1.6)
|
25
25
|
rack (~> 2.0)
|
26
26
|
rack-test (>= 0.6.3)
|
27
27
|
rails-dom-testing (~> 2.0)
|
28
28
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
29
|
-
actionview (5.1.
|
30
|
-
activesupport (= 5.1.
|
29
|
+
actionview (5.1.6)
|
30
|
+
activesupport (= 5.1.6)
|
31
31
|
builder (~> 3.1)
|
32
32
|
erubi (~> 1.4)
|
33
33
|
rails-dom-testing (~> 2.0)
|
34
34
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
35
|
-
activejob (5.1.
|
36
|
-
activesupport (= 5.1.
|
35
|
+
activejob (5.1.6)
|
36
|
+
activesupport (= 5.1.6)
|
37
37
|
globalid (>= 0.3.6)
|
38
|
-
activemodel (5.1.
|
39
|
-
activesupport (= 5.1.
|
40
|
-
activerecord (5.1.
|
41
|
-
activemodel (= 5.1.
|
42
|
-
activesupport (= 5.1.
|
38
|
+
activemodel (5.1.6)
|
39
|
+
activesupport (= 5.1.6)
|
40
|
+
activerecord (5.1.6)
|
41
|
+
activemodel (= 5.1.6)
|
42
|
+
activesupport (= 5.1.6)
|
43
43
|
arel (~> 8.0)
|
44
|
-
activesupport (5.1.
|
44
|
+
activesupport (5.1.6)
|
45
45
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
46
|
-
i18n (
|
46
|
+
i18n (>= 0.7, < 2)
|
47
47
|
minitest (~> 5.1)
|
48
48
|
tzinfo (~> 1.1)
|
49
49
|
arel (8.0.0)
|
50
50
|
builder (3.2.3)
|
51
51
|
colorize (0.8.1)
|
52
52
|
concurrent-ruby (1.0.5)
|
53
|
-
crass (1.0.
|
53
|
+
crass (1.0.4)
|
54
54
|
diff-lcs (1.3)
|
55
55
|
docile (1.3.0)
|
56
56
|
erubi (1.7.1)
|
57
57
|
globalid (0.4.1)
|
58
58
|
activesupport (>= 4.2.0)
|
59
|
-
i18n (0.
|
59
|
+
i18n (1.0.0)
|
60
60
|
concurrent-ruby (~> 1.0)
|
61
61
|
json (2.1.0)
|
62
62
|
loofah (2.2.2)
|
@@ -72,28 +72,28 @@ GEM
|
|
72
72
|
nokogiri (1.8.2)
|
73
73
|
mini_portile2 (~> 2.3.0)
|
74
74
|
rack (2.0.4)
|
75
|
-
rack-test (0.
|
75
|
+
rack-test (1.0.0)
|
76
76
|
rack (>= 1.0, < 3)
|
77
|
-
rails (5.1.
|
78
|
-
actioncable (= 5.1.
|
79
|
-
actionmailer (= 5.1.
|
80
|
-
actionpack (= 5.1.
|
81
|
-
actionview (= 5.1.
|
82
|
-
activejob (= 5.1.
|
83
|
-
activemodel (= 5.1.
|
84
|
-
activerecord (= 5.1.
|
85
|
-
activesupport (= 5.1.
|
77
|
+
rails (5.1.6)
|
78
|
+
actioncable (= 5.1.6)
|
79
|
+
actionmailer (= 5.1.6)
|
80
|
+
actionpack (= 5.1.6)
|
81
|
+
actionview (= 5.1.6)
|
82
|
+
activejob (= 5.1.6)
|
83
|
+
activemodel (= 5.1.6)
|
84
|
+
activerecord (= 5.1.6)
|
85
|
+
activesupport (= 5.1.6)
|
86
86
|
bundler (>= 1.3.0)
|
87
|
-
railties (= 5.1.
|
87
|
+
railties (= 5.1.6)
|
88
88
|
sprockets-rails (>= 2.0.0)
|
89
89
|
rails-dom-testing (2.0.3)
|
90
90
|
activesupport (>= 4.2.0)
|
91
91
|
nokogiri (>= 1.6)
|
92
92
|
rails-html-sanitizer (1.0.4)
|
93
93
|
loofah (~> 2.2, >= 2.2.2)
|
94
|
-
railties (5.1.
|
95
|
-
actionpack (= 5.1.
|
96
|
-
activesupport (= 5.1.
|
94
|
+
railties (5.1.6)
|
95
|
+
actionpack (= 5.1.6)
|
96
|
+
activesupport (= 5.1.6)
|
97
97
|
method_source
|
98
98
|
rake (>= 0.8.7)
|
99
99
|
thor (>= 0.18.1, < 2.0)
|
data/documentation/parameter.md
CHANGED
data/lib/oas_objs/example_obj.rb
CHANGED
@@ -7,14 +7,16 @@ module OpenApi
|
|
7
7
|
class ExampleObj < Hash
|
8
8
|
include Helpers
|
9
9
|
|
10
|
-
attr_accessor :processed, :examples_hash, :keys_of_value
|
10
|
+
attr_accessor :processed, :examples_hash, :example_value, :keys_of_value
|
11
11
|
|
12
|
-
def initialize(
|
13
|
-
self.examples_hash =
|
12
|
+
def initialize(exp, keys_of_value = nil, multiple: false)
|
13
|
+
multiple ? self.examples_hash = exp : self.example_value = exp
|
14
14
|
self.keys_of_value = keys_of_value
|
15
15
|
end
|
16
16
|
|
17
17
|
def process
|
18
|
+
return self.processed = example_value if example_value
|
19
|
+
|
18
20
|
self.processed =
|
19
21
|
examples_hash.map do |(name, value)|
|
20
22
|
value =
|
@@ -13,7 +13,7 @@ module OpenApi
|
|
13
13
|
schema_type = hash.values_at(:type, :data).compact.first
|
14
14
|
exp_by = schema_type.keys if exp_by == :all
|
15
15
|
|
16
|
-
self.examples = ExampleObj.new(examples_hash, exp_by) if examples_hash.present?
|
16
|
+
self.examples = ExampleObj.new(examples_hash, exp_by, multiple: true) if examples_hash.present?
|
17
17
|
self.media_type = media_type_mapping media_type
|
18
18
|
self.schema = SchemaObj.new(schema_type, hash)
|
19
19
|
end
|
data/lib/oas_objs/schema_obj.rb
CHANGED
@@ -91,9 +91,10 @@ module OpenApi
|
|
91
91
|
|
92
92
|
def pattern_default_and_other
|
93
93
|
{
|
94
|
-
pattern:
|
95
|
-
default:
|
96
|
-
|
94
|
+
pattern: _pattern.is_a?(String) ? _pattern : _pattern&.inspect&.delete('/'),
|
95
|
+
default: _default,
|
96
|
+
example: _exp.present? ? ExampleObj.new(_exp).process : nil,
|
97
|
+
examples: _exps.present? ? ExampleObj.new(_exps, self[:exp_by], multiple: true).process : nil,
|
97
98
|
as: _as, permit: _permit, not_permit: _npermit, req_if: _req_if, opt_if: _opt_if, blankable: _blank
|
98
99
|
}
|
99
100
|
end
|
@@ -104,18 +105,20 @@ module OpenApi
|
|
104
105
|
_value: %i[ must_be value allowable_value ],
|
105
106
|
_range: %i[ range number_range ],
|
106
107
|
_length: %i[ length lth size ],
|
107
|
-
_is: %i[ is_a is ], # NOT OAS Spec, see documentation/parameter.md
|
108
108
|
_format: %i[ format fmt ],
|
109
109
|
_pattern: %i[ pattern regexp pt reg ],
|
110
110
|
_default: %i[ default dft default_value ],
|
111
111
|
_desc: %i[ desc description d ],
|
112
112
|
__desc: %i[ desc! description! d! ],
|
113
|
+
_exp: %i[ example ],
|
114
|
+
_exps: %i[ examples ],
|
115
|
+
_is: %i[ is_a is ], # NOT OAS Spec, see documentation/parameter.md
|
113
116
|
_as: %i[ as to for map mapping ], # NOT OAS Spec, it's for zero-params_processor
|
114
|
-
_permit: %i[ permit pmt ], #
|
115
|
-
_npermit: %i[ npmt not_permit unpermit ], #
|
116
|
-
_req_if: %i[ req_if req_when ], #
|
117
|
-
_opt_if: %i[ opt_if opt_when ], #
|
118
|
-
_blank: %i[ blank blankable ], #
|
117
|
+
_permit: %i[ permit pmt ], # ditto
|
118
|
+
_npermit: %i[ npmt not_permit unpermit ], # ditto
|
119
|
+
_req_if: %i[ req_if req_when ], # ditto
|
120
|
+
_opt_if: %i[ opt_if opt_when ], # ditto
|
121
|
+
_blank: %i[ blank blankable ], # ditto
|
119
122
|
}.each do |key, aliases|
|
120
123
|
define_method key do
|
121
124
|
return self[key] unless self[key].nil?
|
data/lib/open_api/dsl.rb
CHANGED
@@ -27,9 +27,11 @@ module OpenApi
|
|
27
27
|
def components &block
|
28
28
|
doc_tag if @doc_info.nil?
|
29
29
|
structure = %i[ schemas responses parameters examples requestBodies securitySchemes ].map { |k| [k, { }] }.to_h
|
30
|
-
current_doc =
|
30
|
+
current_doc = Components.new.merge!(structure)
|
31
31
|
current_doc.instance_exec(&block)
|
32
32
|
current_doc.process_objs
|
33
|
+
|
34
|
+
(@doc_info[:components] ||= { }).deep_merge!(current_doc)
|
33
35
|
end
|
34
36
|
|
35
37
|
def api action, summary = '', http: http_method = nil, skip: [ ], use: [ ], &block
|
@@ -37,7 +39,7 @@ module OpenApi
|
|
37
39
|
# select the routing info (corresponding to the current method) from routing list.
|
38
40
|
action_path = "#{@route_base ||= controller_path}##{action}"
|
39
41
|
routes = ctrl_routes_list&.select { |api| api[:action_path].match?(/^#{action_path}$/) }
|
40
|
-
return puts ' ZRO'.red + " Route mapping failed: #{
|
42
|
+
return puts ' ZRO'.red + " Route mapping failed: #{action_path}" if routes.blank?
|
41
43
|
|
42
44
|
api = Api.new(action_path, skip: Array(skip), use: Array(use))
|
43
45
|
.merge! description: '', summary: summary, operationId: action, tags: [@doc_tag],
|
data/lib/open_api/dsl/api.rb
CHANGED
@@ -132,7 +132,7 @@ module OpenApi
|
|
132
132
|
|
133
133
|
def param_examples exp_by = :all, examples_hash
|
134
134
|
exp_by = self[:parameters].map(&:name) if exp_by == :all
|
135
|
-
self[:examples] = ExampleObj.new(examples_hash, exp_by).process
|
135
|
+
self[:examples] = ExampleObj.new(examples_hash, exp_by, multiple: true).process
|
136
136
|
end
|
137
137
|
|
138
138
|
alias examples param_examples
|
@@ -15,7 +15,7 @@ module OpenApi
|
|
15
15
|
arrow_enable :schema
|
16
16
|
|
17
17
|
def example component_key, examples_hash
|
18
|
-
self[:examples][component_key] = ExampleObj.new(examples_hash).process
|
18
|
+
self[:examples][component_key] = ExampleObj.new(examples_hash, multiple: true).process
|
19
19
|
end
|
20
20
|
|
21
21
|
arrow_enable :example
|
data/lib/open_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zero-rails_openapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zhandao
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
179
|
version: '0'
|
180
180
|
requirements: []
|
181
181
|
rubyforge_project:
|
182
|
-
rubygems_version: 2.
|
182
|
+
rubygems_version: 2.7.3
|
183
183
|
signing_key:
|
184
184
|
specification_version: 4
|
185
185
|
summary: Concise DSL for generating OpenAPI3 documentation.
|