@@ -9,17 +9,18 @@ class Components < Hash
9
9
def schema component_key , type = nil , one_of : nil , all_of : nil , any_of : nil , not : nil , **schema_hash
10
10
( schema_hash = type ) and ( type = type . delete ( :type ) ) if type . is_a? ( Hash ) && type . key? ( :type )
11
11
type ||= schema_hash [ :type ]
12
- type ||= load_schema component_key if component_key . try ( :superclass ) == Config . active_record_base . to_s . constantize
12
+ type ||= load_schema component_key if component_key . try ( :superclass ) == Config . active_record_base || ApplicationRecord
13
13
14
- combined_schema = one_of || all_of || any_of || ( _not = binding . local_variable_get ( :not ) )
14
+ combined_schema = ( _not = binding . local_variable_get ( :not ) ) || one_of || all_of || any_of
15
15
combined_schema = CombinedSchema . new ( one_of : one_of , all_of : all_of , any_of : any_of , _not : _not ) if combined_schema
16
16
( self [ :schemas ] ||= { } ) [ component_key . to_s . to_sym ] = combined_schema &.process || SchemaObj . new ( type , schema_hash ) . process
17
17
end
18
18
arrow_enable :schema
19
19
20
- def example summary , example_hash
21
- # TODO
20
+ def example component_key , examples_hash
21
+ ( self [ :examples ] ||= { } ) [ component_key ] = ExampleObj . new ( examples_hash ) . process
22
22
end
23
+ arrow_enable :example
23
24
24
25
def param component_key , param_type , name , type , required , schema_hash = { }
25
26
( self [ :parameters ] ||= { } ) [ component_key ] = ParamObj . new ( name , param_type , type , required , schema_hash ) . process
@@ -60,15 +61,18 @@ def security_scheme scheme_name, other_info# = { }
60
61
def base_auth scheme_name , other_info = { }
61
62
security_scheme scheme_name , { type : 'http' , scheme : 'basic' } . merge ( other_info )
62
63
end
64
+ arrow_enable :base_auth
63
65
64
66
def bearer_auth scheme_name , format = 'JWT' , other_info = { }
65
67
security_scheme scheme_name , { type : 'http' , scheme : 'bearer' , bearerFormat : format } . merge ( other_info )
66
68
end
69
+ arrow_enable :bearer_auth
67
70
68
71
def api_key scheme_name , field :, in :, **other_info
69
72
_in = binding . local_variable_get ( :in )
70
73
security_scheme scheme_name , { type : 'apiKey' , name : field , in : _in } . merge ( other_info )
71
74
end
75
+ arrow_enable :api_key
72
76
73
77
def _process_objs
74
78
self [ :responses ] &.each do |code , obj |
0 commit comments