Module: OpenApi::Endpoints::Controller::ClassMethods
- Defined in:
- lib/open-api/endpoints.rb
Instance Method Summary collapse
- #open_api_action(action, metadata = nil) ⇒ Object
- #open_api_controller(metadata = nil) ⇒ Object
- #open_api_endpoint_metadata(action, path, opts = {}) ⇒ Object
- #open_api_path(path, metadata = nil) ⇒ Object
- #open_api_path_param(path_param, param_metadata) ⇒ Object
Instance Method Details
#open_api_action(action, metadata = nil) ⇒ Object
138 139 140 141 142 |
# File 'lib/open-api/endpoints.rb', line 138 def open_api_action(action, = nil) ||= {} if .present? OpenApi::Utils.(, action, , arg_name: 'action') end |
#open_api_controller(metadata = nil) ⇒ Object
131 132 133 134 135 136 |
# File 'lib/open-api/endpoints.rb', line 131 def open_api_controller( = nil) return ( || {}).deep_dup if .blank? fail 'Expected Hash argument for open_api_controller()!' unless .is_a?(Hash) OpenApi::Endpoints.( ||= {}, ) nil end |
#open_api_endpoint_metadata(action, path, opts = {}) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/open-api/endpoints.rb', line 144 def (action, path, opts = {}) path = OpenApi::Endpoints.relative_path(path, opts[:base_path]) controller_class_hierarchy = OpenApi::Utils.controller_class_hierarchy(self) = {} controller_class_hierarchy.each do |controller_class| OpenApi::Endpoints.(, controller_class.send(:open_api_controller), opts) end = {} controller_class_hierarchy.each do |controller_class| OpenApi::Endpoints.(, controller_class.send(:open_api_path, path), opts) end = {} controller_class_hierarchy.each do |controller_class| OpenApi::Endpoints.(, controller_class.send(:open_api_action, action), opts) end OpenApi::Endpoints.(, OpenApi::Endpoints.(, , opts), opts) end |
#open_api_path(path, metadata = nil) ⇒ Object
118 119 120 121 122 |
# File 'lib/open-api/endpoints.rb', line 118 def open_api_path(path, = nil) ||= {} if .present? OpenApi::Utils.(, path, , arg_name: 'path') end |
#open_api_path_param(path_param, param_metadata) ⇒ Object
124 125 126 127 128 129 |
# File 'lib/open-api/endpoints.rb', line 124 def open_api_path_param(path_param, ) regexp = %r{(\A|\/)\:#{path_param}(\Z|\/)|\(\.\:#{path_param}\)} open_api_path regexp, path_params: { path_param.to_s => { type: :integer, required: true }.merge() } end |