apipie-dsl 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/apipie_dsl_helper.rb +8 -5
- data/app/views/apipie_dsl/apipie_dsls/_params.html.erb +2 -1
- data/app/views/apipie_dsl/apipie_dsls/index.html.erb +1 -1
- data/app/views/apipie_dsl/apipie_dsls/plain.html.erb +2 -2
- data/app/views/apipie_dsl/apipie_dsls/static.html.erb +2 -2
- data/lib/apipie_dsl/class_description.rb +3 -3
- data/lib/apipie_dsl/dsl.rb +13 -9
- data/lib/apipie_dsl/errors.rb +4 -0
- data/lib/apipie_dsl/parameter_description.rb +26 -26
- data/lib/apipie_dsl/return_description.rb +0 -2
- data/lib/apipie_dsl/tasks_utils.rb +2 -2
- data/lib/apipie_dsl/utils.rb +1 -12
- data/lib/apipie_dsl/validator.rb +3 -3
- data/lib/apipie_dsl/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95dfead8f64abaa0afb0acb4c8af97c43a484d0486596a08049420baff6ba9a4
|
4
|
+
data.tar.gz: 5f454030f583bd23a2728693c6950c6c145223289448f1f6ae681c021cc0897f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0d8dccd8fdaa5bbd2c8cc1ef4a89cdda096fa000ace242518f5196a420cf7cc7e62f4790d3f9e6c1b7335bdc2dd65c5b6dbe5133fceb7b6477376d3bf95d640
|
7
|
+
data.tar.gz: c5a0a6ba9167b2bf13e117ca608d997689ab97eb76e422a69423dab1c8152c7e203594dde8d9d6216e661c4116a5d6f5f113ed95913b41b8d41cb6418f8f3232
|
@@ -49,11 +49,11 @@ module ApipieDslHelper
|
|
49
49
|
def apipie_erb_wrap(content, mode: :loud, open_trim: false, close_trim: false)
|
50
50
|
case mode
|
51
51
|
when :loud
|
52
|
-
|
52
|
+
"<%= #{content} #{close_trim ? '-' : ''}%>"
|
53
53
|
when :comment
|
54
|
-
|
54
|
+
"<%# #{content} #{close_trim ? '-' : ''}%>"
|
55
55
|
else
|
56
|
-
"<%#{open_trim ? '-
|
56
|
+
"<%#{open_trim ? '-' : ''} #{content} #{close_trim ? '-' : ''}%>"
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -65,6 +65,8 @@ module ApipieDslHelper
|
|
65
65
|
"\"\""
|
66
66
|
when Symbol
|
67
67
|
":#{default}"
|
68
|
+
when String
|
69
|
+
"\"#{default}\""
|
68
70
|
else
|
69
71
|
default
|
70
72
|
end
|
@@ -142,9 +144,10 @@ module ApipieDslHelper
|
|
142
144
|
end
|
143
145
|
|
144
146
|
def current_version(classes)
|
145
|
-
|
147
|
+
case classes
|
148
|
+
when Array
|
146
149
|
classes.first[:version]
|
147
|
-
|
150
|
+
when Hash
|
148
151
|
classes.values.first[:version]
|
149
152
|
else
|
150
153
|
raise ApipieDSL::Error, "Cannot find current version for #{classes}"
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
<h1 class='page-header'><%= t('apipie_dsl.classes') %></h1>
|
16
16
|
|
17
|
-
<% @doc[:classes].
|
17
|
+
<% @doc[:classes].sort_by { |id, c| c[:name] }.each do |id, klass| %>
|
18
18
|
<% next unless klass[:show] && in_section?(@section, klass[:id]) %>
|
19
19
|
<h2>
|
20
20
|
<a href='<%= klass[:doc_url] %><%= @doc[:link_extension] %>'>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% @doc[:classes].sort_by
|
1
|
+
<% @doc[:classes].sort_by { |id, c| c[:name] }.each do |key, klass| %>
|
2
2
|
<% next unless klass[:show] %>
|
3
3
|
<h4><a href='#<%= key %>'><%= klass[:name] %></a></h4>
|
4
4
|
<ul>
|
@@ -14,7 +14,7 @@
|
|
14
14
|
</ul>
|
15
15
|
<% end %>
|
16
16
|
|
17
|
-
<% @doc[:classes].sort_by
|
17
|
+
<% @doc[:classes].sort_by { |id, c| c[:name] }.each do |key, klass| %>
|
18
18
|
<% next unless klass[:show] %>
|
19
19
|
<hr/>
|
20
20
|
<div>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% @doc[:classes].sort_by
|
1
|
+
<% @doc[:classes].sort_by { |id, c| c[:name] }.each do |key, klass| %>
|
2
2
|
<% next unless klass[:show] %>
|
3
3
|
<h4><a href='#<%= key %>'><%= klass[:name] %></a></h4>
|
4
4
|
<ul>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
<hr>
|
20
20
|
|
21
|
-
<% @doc[:classes].sort_by
|
21
|
+
<% @doc[:classes].sort_by { |id, c| c[:name] }.each do |key, klass| %>
|
22
22
|
<% next unless klass[:show] %>
|
23
23
|
<ul class='breadcrumb' id='<%= key %>'>
|
24
24
|
<li><a href='#'><%= @doc[:name] %></a><span class='divider'>/</span></li>
|
@@ -23,7 +23,7 @@ module ApipieDSL
|
|
23
23
|
@full_description = ApipieDSL.markup_to_html(dsl_data[:description]) if dsl_data[:description]
|
24
24
|
@short_description = dsl_data[:short_description] || @short_description
|
25
25
|
@tag_list = dsl_data[:tag_list]
|
26
|
-
if dsl_data[:meta]
|
26
|
+
if dsl_data[:meta].is_a?(Hash)
|
27
27
|
@metadata&.merge!(dsl_data[:meta])
|
28
28
|
elsif dsl_data[:meta]
|
29
29
|
@metadata = dsl_data[:meta]
|
@@ -98,8 +98,8 @@ module ApipieDSL
|
|
98
98
|
full_description: ApipieDSL.translate(@full_description, lang),
|
99
99
|
version: version,
|
100
100
|
metadata: @metadata,
|
101
|
-
properties: @properties.map { |prop_desc| prop_desc.docs(section, lang) },
|
102
|
-
methods: methods,
|
101
|
+
properties: @properties.map { |prop_desc| prop_desc.docs(section, lang) }.sort_by { |p| p[:name] },
|
102
|
+
methods: methods.sort_by { |m| m[:name] },
|
103
103
|
deprecated: @deprecated,
|
104
104
|
show: @show
|
105
105
|
}
|
data/lib/apipie_dsl/dsl.rb
CHANGED
@@ -202,9 +202,10 @@ module ApipieDSL
|
|
202
202
|
options[:desc] = desc_or_options
|
203
203
|
end
|
204
204
|
|
205
|
-
|
205
|
+
case retobj_or_options
|
206
|
+
when Hash
|
206
207
|
options.merge!(retobj_or_options)
|
207
|
-
|
208
|
+
when Symbol
|
208
209
|
options[:param_group] = retobj_or_options
|
209
210
|
else
|
210
211
|
options[:object_of] ||= retobj_or_options
|
@@ -414,7 +415,7 @@ module ApipieDSL
|
|
414
415
|
def self.update_method_desc(method_desc, dsl_data)
|
415
416
|
method_desc.full_description = dsl_data[:description] || method_desc.full_description
|
416
417
|
method_desc.short_description = dsl_data[:short_description] || method_desc.short_description
|
417
|
-
if dsl_data[:meta]
|
418
|
+
if dsl_data[:meta].is_a?(Hash)
|
418
419
|
method_desc.metadata&.merge!(dsl_data[:meta])
|
419
420
|
else
|
420
421
|
method_desc.metadata = dsl_data[:meta]
|
@@ -454,9 +455,10 @@ module ApipieDSL
|
|
454
455
|
end
|
455
456
|
|
456
457
|
def apipie(context = :method, desc_or_options = nil, options = {}, &block)
|
457
|
-
|
458
|
+
case desc_or_options
|
459
|
+
when Hash
|
458
460
|
options = options.merge(desc_or_options)
|
459
|
-
|
461
|
+
when String
|
460
462
|
options[:desc] = desc_or_options
|
461
463
|
end
|
462
464
|
options[:name] ||= context.to_s
|
@@ -507,9 +509,10 @@ module ApipieDSL
|
|
507
509
|
private
|
508
510
|
|
509
511
|
def prepare_delegatee(scope, desc_or_options, options, &block)
|
510
|
-
|
512
|
+
case desc_or_options
|
513
|
+
when Hash
|
511
514
|
options = options.merge(desc_or_options)
|
512
|
-
|
515
|
+
when String
|
513
516
|
options[:desc] = desc_or_options
|
514
517
|
end
|
515
518
|
|
@@ -528,9 +531,10 @@ module ApipieDSL
|
|
528
531
|
include ApipieDSL::Delegatable
|
529
532
|
|
530
533
|
def apipie(context = :method, desc_or_options = nil, options = {}, &block)
|
531
|
-
|
534
|
+
case desc_or_options
|
535
|
+
when Hash
|
532
536
|
options = options.merge(desc_or_options)
|
533
|
-
|
537
|
+
when String
|
534
538
|
options[:desc] = desc_or_options
|
535
539
|
end
|
536
540
|
options[:name] ||= context.to_s
|
data/lib/apipie_dsl/errors.rb
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
module ApipieDSL
|
4
4
|
class Error < StandardError; end
|
5
|
+
|
5
6
|
class ParamError < Error
|
6
7
|
attr_accessor :param
|
7
8
|
|
8
9
|
def initialize(param)
|
10
|
+
super
|
9
11
|
@param = param
|
10
12
|
end
|
11
13
|
end
|
@@ -46,6 +48,7 @@ module ApipieDSL
|
|
46
48
|
attr_accessor :value
|
47
49
|
|
48
50
|
def initialize(value)
|
51
|
+
super
|
49
52
|
@value = value
|
50
53
|
end
|
51
54
|
|
@@ -70,6 +73,7 @@ module ApipieDSL
|
|
70
73
|
attr_reader :value
|
71
74
|
|
72
75
|
def initialize(value)
|
76
|
+
super
|
73
77
|
@value = value
|
74
78
|
end
|
75
79
|
|
@@ -34,40 +34,40 @@ module ApipieDSL
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def initialize(method_description, name, validator, desc_or_options = nil, options = {}, &block)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
if desc_or_options.is_a?(Hash)
|
38
|
+
options = options.merge(desc_or_options)
|
39
|
+
elsif desc_or_options.is_a?(String)
|
40
|
+
options[:desc] = desc_or_options
|
41
|
+
elsif !desc_or_options.nil?
|
42
|
+
raise ArgumentError, 'Parameter description: expected description or options as 3rd parameter'
|
43
|
+
end
|
44
44
|
|
45
|
-
|
45
|
+
@options = options.transform_keys(&:to_sym)
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
47
|
+
@method_description = method_description
|
48
|
+
@name = name
|
49
|
+
@desc = @options[:desc]
|
50
|
+
@type = @options[:type] || :required
|
51
|
+
@schema = @options[:schema]
|
52
|
+
@default_value = @options[:default]
|
53
|
+
@parent = @options[:parent]
|
54
|
+
@metadata = @options[:meta]
|
55
|
+
@show = @options.key?(:show) ? @options[:show] : true
|
56
56
|
|
57
|
-
|
57
|
+
return unless validator
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
@validator = if validator.is_a?(String)
|
60
|
+
ApipieDSL::Validator::Lazy.new(self, validator, @options, block)
|
61
|
+
else
|
62
|
+
ApipieDSL::Validator::BaseValidator.find(self, validator, @options, block)
|
63
|
+
end
|
64
|
+
raise StandardError, "Validator for #{validator} not found." unless @validator
|
65
65
|
end
|
66
66
|
|
67
67
|
def validator
|
68
|
-
|
68
|
+
return @validator unless @validator.is_a?(ApipieDSL::Validator::Lazy)
|
69
69
|
|
70
|
-
|
70
|
+
@validator = @validator.build
|
71
71
|
end
|
72
72
|
|
73
73
|
def validate(value)
|
@@ -12,8 +12,6 @@ module ApipieDSL
|
|
12
12
|
@param_group = { scope: @scope }
|
13
13
|
@options = options
|
14
14
|
@return_type = (@options.keys & %i[array_of one_of object_of param_group]).first
|
15
|
-
|
16
|
-
return unless @options[@return_type].is_a?(::Class)
|
17
15
|
end
|
18
16
|
|
19
17
|
# this routine overrides Param#default_param_group_scope
|
@@ -21,8 +21,8 @@ module ApipieDSL
|
|
21
21
|
base_paths.unshift("#{Rails.root}/app/views/apipie_dsl/apipie_dsls") if File.directory?("#{Rails.root}/app/views/apipie_dsl/apipie_dsls")
|
22
22
|
end
|
23
23
|
layouts_paths = [File.expand_path('../../app/views/layouts', __dir__)]
|
24
|
-
if ApipieDSL.configuration.rails?
|
25
|
-
layouts_paths.unshift("#{Rails.root}/app/views/layouts")
|
24
|
+
if ApipieDSL.configuration.rails? && File.directory?("#{Rails.root}/app/views/layouts/apipie_dsl")
|
25
|
+
layouts_paths.unshift("#{Rails.root}/app/views/layouts")
|
26
26
|
end
|
27
27
|
paths = ActionView::PathSet.new(base_paths + layouts_paths)
|
28
28
|
@renderer = ActionView::Base.new(paths, {})
|
data/lib/apipie_dsl/utils.rb
CHANGED
@@ -60,18 +60,7 @@ module ApipieDSL
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
64
|
-
class Hash
|
65
|
-
def transform_keys
|
66
|
-
result = {}
|
67
|
-
each do |key, value|
|
68
|
-
new_key = yield key
|
69
|
-
result[new_key] = value
|
70
|
-
end
|
71
|
-
result
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
63
|
+
|
75
64
|
if defined? Rails
|
76
65
|
class Module
|
77
66
|
# https://github.com/rails/rails/pull/35035
|
data/lib/apipie_dsl/validator.rb
CHANGED
@@ -17,6 +17,7 @@ module ApipieDSL
|
|
17
17
|
BaseValidator.find(@param_description, @argument.constantize, @options, @block)
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
20
21
|
# To create a new validator, inherit from ApipieDSL::Validator::BaseValidator
|
21
22
|
# and implement class method 'build' and instance method 'validate'
|
22
23
|
class BaseValidator
|
@@ -49,6 +50,7 @@ module ApipieDSL
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def self.inherited(subclass)
|
53
|
+
super(subclass)
|
52
54
|
@validators ||= []
|
53
55
|
@validators.unshift(subclass)
|
54
56
|
end
|
@@ -325,9 +327,7 @@ module ApipieDSL
|
|
325
327
|
return false unless value.is_a?(Hash)
|
326
328
|
|
327
329
|
@hash_params&.each do |name, param|
|
328
|
-
if ApipieDSL.configuration.validate_value?
|
329
|
-
param.validate(value[name]) if value.key?(name)
|
330
|
-
end
|
330
|
+
param.validate(value[name]) if ApipieDSL.configuration.validate_value? && value.key?(name)
|
331
331
|
end
|
332
332
|
true
|
333
333
|
end
|
data/lib/apipie_dsl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apipie-dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleh Fedorenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -206,14 +206,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
206
206
|
requirements:
|
207
207
|
- - ">="
|
208
208
|
- !ruby/object:Gem::Version
|
209
|
-
version: 2.
|
209
|
+
version: 2.5.0
|
210
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
211
|
requirements:
|
212
212
|
- - ">="
|
213
213
|
- !ruby/object:Gem::Version
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
|
-
rubygems_version: 3.
|
216
|
+
rubygems_version: 3.0.8
|
217
217
|
signing_key:
|
218
218
|
specification_version: 4
|
219
219
|
summary: Ruby DSL documentation tool
|