Module: Minitest::OpenAPI::Webhook

Defined in:
lib/minitest/openapi/webhook.rb

Defined Under Namespace

Classes: TestCase

Class Method Summary collapse

Class Method Details

.build(metadata, test_case) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/minitest/openapi/webhook.rb', line 6

def self.build(, test_case)
  export_file_path = Minitest::OpenAPI.path.yield_self { |p| p.is_a?(Proc) ? p.call(test_case) : p }
  file_path_data = Minitest::OpenAPI.webhooks[export_file_path]

  if file_path_data[[:endpoint]]
    if file_path_data[[:endpoint]][[:method]]
      file_path_data[[:endpoint]][[:method]][:responses].merge!({ [:status] => {} })
    else
      file_path_data[[:endpoint]].merge! self.format_endpoint()
    end
  else
    file_path_data.merge!([:endpoint] => self.format_endpoint())
  end
end

.format_endpoint(metadata) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/minitest/openapi/webhook.rb', line 21

def self.format_endpoint()
  {
    [:method] => {
      parameters: [],
      responses: {
        [:status] => {},
        default: {}
      }
    }
  }
end