0

我有一个遗留端点(我无法更改),我需要为其编写一个 Rswag 规范。

端点将 awebsite_uuid作为查询参数,将aemail作为正文参数。

目前的测试如下所示:

  path('/api/leads/request_reset_password') do
    post('request a password reset email') do
      tags 'Leads'
      produces 'application/json'
      consumes 'application/json'

      parameter name: :website_uuid, in: :query, type: :string, description: 'Website UUID'
      parameter name: :email, in: :body,  type: :string, description: 'Email of lead requiring password reset'

      response(204, 'email sent') do

        let(:website_uuid) { website.uuid }
        let(:email) { lead.email }
        let(:params) { { email: lead.email } }

        describe 'with valid parameters' do
          it 'blah' do
            binding.pry
          end
        end
      end
    end
  end

当我点击 时binding.pry,我检查我的参数:

[1] pry> response.request.params
=> {
      "_json"=>"nobody@example.com", 
      "website_uuid"=>"f63cdc54-qf02-400e-a96c-5722f7d00fc0", 
      "format"=>:json, 
      "controller"=>"api/leads", 
      "action"=>"request_reset_password", 
      "lead"=>{}
   }

为什么电子邮件会显示在此_json参数中?

参数在哪里email

为什么lead我没有指定它时会出现一个空参数?

4

0 回答 0