Class: RSpec::Swag::ResponseValidator

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ResponseValidator.



11
12
13
# File 'lib/rspec/swag/response_validator.rb', line 11

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

Instance Method Details

#validate!(metadata, response) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/rspec/swag/response_validator.rb', line 15

def validate!(, response)
  swagger_doc = @config.get_openapi_spec([:openapi_spec] || [:swagger_doc])

  validate_code!(, response)
  validate_headers!(, response.headers)
  validate_body!(, swagger_doc, response.body)
end