0

I'm using RSwag (2.7) to generate API documentation based on tests on Rails 6.1. The problem is that using the same method specified in the official documentation I get an RSpec error.

I need to add a pretty complex request body and the documentation https://github.com/rswag/rswag states you can use

request_body_example value: { some_field: 'Foo' }, name: 'request_example_1', summary: 'A request example'

to specify a body request example for your request. So I have this test:

post 'Creates holdings in bulk' do
  tags 'Holdings'
  produces 'application/json'
  consumes 'application/json'
  request_body_example name: 'some name' summary: 'Request example description', value: { 'some hash' }

  it_behaves_like '200_response', 'Holdings'
end

But it raises:

NoMethodError:
  undefined method `request_body_example' for RSpec::ExampleGroups::Holdings::Bulk::HoldingsBulk::Post:Class
  Did you mean?  require_or_load

Is there something I'm doing wrong? It seems like it's the same as the documentation.

0 Answers0