@@ -28,20 +28,19 @@ def process_for(param_name = nil, options = { desc_inside: false })
28
28
return processed if @preprocessed
29
29
30
30
processed . merge! processed_type
31
- reduceee processed_enum_and_length ,
32
- processed_range ,
33
- processed_is_and_format ( param_name ) ,
34
- {
35
- pattern : _pattern &.inspect &.delete ( '/' ) ,
36
- default : _default ,
37
- as : _as ,
38
- permit : _permit ,
39
- not_permit : _npermit ,
40
- examples : self [ :examples ] . present? ? ExampleObj . new ( self [ :examples ] ) . process : nil
41
- }
31
+ reducx processed_enum_and_length ,
32
+ processed_range ,
33
+ processed_is_and_format ( param_name ) ,
34
+ {
35
+ pattern : _pattern &.inspect &.delete ( '/' ) ,
36
+ default : '_default' ,
37
+ examples : self [ :examples ] . present? ? ExampleObj . new ( self [ :examples ] , self [ :exp_by ] ) . process : nil ,
38
+ } ,
39
+ { as : _as , permit : _permit , not_permit : _npermit , req_if : _req_if , opt_if : _opt_if }
42
40
then_merge!
41
+ processed [ :default ] = _default unless _default . nil?
43
42
44
- reduceee ( processed_desc options ) . then_merge!
43
+ reducx ( processed_desc options ) . then_merge!
45
44
end
46
45
47
46
alias process process_for
@@ -154,16 +153,12 @@ def processed_enum_and_length
154
153
155
154
# generate length range fields by _lth array
156
155
lth = _length || [ ]
157
- if self [ :type ] == 'array'
158
- {
159
- minItems : lth . is_a? ( Array ) ? lth . first : nil ,
160
- maxItems : lth . is_a? ( Array ) ? lth . last : nil
161
- }
156
+ max = lth . is_a? ( Array ) ? lth . first : ( "#{ lth } " . match? ( 'ge' ) ? "#{ lth } " . split ( '_' ) . last . to_i : nil )
157
+ min = lth . is_a? ( Array ) ? lth . last : ( "#{ lth } " . match? ( 'le' ) ? "#{ lth } " . split ( '_' ) . last . to_i : nil )
158
+ if processed [ :type ] == 'array'
159
+ { minItems : max , maxItems : min }
162
160
else
163
- {
164
- minLength : lth . is_a? ( Array ) ? lth . first : ( "#{ lth } " . match? ( 'ge' ) ? "#{ lth } " . split ( '_' ) . last . to_i : nil ) ,
165
- maxLength : lth . is_a? ( Array ) ? lth . last : ( "#{ lth } " . match? ( 'le' ) ? "#{ lth } " . split ( '_' ) . last . to_i : nil )
166
- }
161
+ { minLength : max , maxLength : min }
167
162
end . merge! ( enum : _enum ) . keep_if &value_present
168
163
end
169
164
@@ -209,6 +204,8 @@ def recognize_is_options_in(name)
209
204
_as : %i[ as to for map mapping ] , # NOT OAS Spec, it's for zero-params_processor
210
205
_permit : %i[ permit pmt ] , # NOT OAS Spec, it's for zero-params_processor
211
206
_npermit : %i[ npmt not_permit unpermit ] , # NOT OAS Spec, it's for zero-params_processor
207
+ _req_if : %i[ req_if req_when ] , # NOT OAS Spec, it's for zero-params_processor
208
+ _opt_if : %i[ opt_if opt_when ] , # NOT OAS Spec, it's for zero-params_processor
212
209
} . each do |key , aliases |
213
210
define_method key do
214
211
aliases . each do |alias_name |
0 commit comments