设置属性时避免招摇中重复键-Rails

问题描述

我应该如何避免招摇过头的重复属性?我有一个非常简单的API,如下所示:

describe 'User' do
  path '/api/v1/users/signup' do
  post 'user registration/sign up' do
    tags 'Users'
    consumes 'application/json'
    parameter name: :user,in: :body,schema: {
      type: :object,properties: {
          email: { type: :string },password: { type: :string },password_confirmation: { type: :string },user_name: { type: :string }
        },required: %w(email password password_confirmation user_name)
      }
      response '200','success' do
        let(:user) { { email: '[email protected]',password: 'User@123.',password_confirmation: 'User@123.',user_name: "UserName"  } }
        run_test!
      end
    end
  end
end

它总是返回这样的对象:

{
  "email": "string","password": "string","password_confirmation": "string","user_name": "string"
}

然后,由于电子邮件在这种情况下是唯一的,因此在第二次执行API时会导致重复问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)