Class: Rswag::Specs::RequestFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/rswag/specs/request_factory.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = ::Rswag::Specs.config) ⇒ RequestFactory

Returns a new instance of RequestFactory.



10
11
12
# File 'lib/rswag/specs/request_factory.rb', line 10

def initialize(config = ::Rswag::Specs.config)
  @config = config
end

Instance Method Details

#build_request(metadata, example) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rswag/specs/request_factory.rb', line 14

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