ayza
ayza

Reputation: 119

rswag gem does not recognize my parameters in rspec

when running RSpec, in the action of controller,(use byebug or pry) the specific value like (email or password) did not exist in the request parameters, and so the result of the test become failed for more details, see my below code

  path '/api/v1/admin/authentications/sign_in' do
    post('admin sign_in') do
      produces 'application/json'
      parameter name: :params, in: :body, schema: {
        type: :object,
        properties: {
          email: { type: :string },
          password: { type: :string }
        },
        required: %w[email password]
      }

      let(:admin) { create(:admin) }
      response('200', 'sign in successfully') do
        let(:params) { { email: admin.email, password: '***' } }
        run_test!
      end
    end
  end

Upvotes: 4

Views: 1936

Answers (2)

thang tran
thang tran

Reputation: 23

I also had the same problem with the latest version of gem rswag. You can change the version of gem to "1.6" to fix it

Upvotes: 0

Moeen
Moeen

Reputation: 412

add consume type for your request:

consumes 'application/json'

Upvotes: 4

Related Questions