Class: RSpec::Swag::RequestFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/swag/request_factory.rb

Overview

rubocop:disable Metrics/ClassLength

Instance Method Summary collapse

Constructor Details

#initialize(config = ::RSpec::Swag.config) ⇒ RequestFactory

Returns a new instance of RequestFactory.



12
13
14
# File 'lib/rspec/swag/request_factory.rb', line 12

def initialize(config = ::RSpec::Swag.config)
  @config = config
end

Instance Method Details

#build_request(metadata, example) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rspec/swag/request_factory.rb', line 16

def build_request(, example)
  swagger_doc = @config.get_openapi_spec([:openapi_spec] || [:swagger_doc])
  parameters = expand_parameters(, swagger_doc, example)

  {}.tap do |request|
    add_verb(request, )
    add_path(request, , swagger_doc, parameters, example)
    add_headers(request, , swagger_doc, parameters, example)
    add_payload(request, parameters, example)
  end
end