0

I am using Apipie gem for documentation. I have created all the documentation which are basics but I am stuck in one api which is create api but finding the contact with query params. The code is below

def create
  @account = Account.find_by(name: params[:name])
  @user = @account.users.find_by(role: 'owner')
  @contact = @user.contacts.find_by(email: contact_params[:email])
  if @contact.present?
    @contact.update(contact_params)
  else
    @contact = @user.contacts.new(contact_params)
    @contact.save
  end
  render json: @contact, status: :ok
rescue StandardError => e
  render json: { error: e.message }, status: :unprocessable_entity
end

def contact_params
  params.require(:contact).permit(:first_name, :last_name, :email)
end

and the url of this api is http://localhost:3000/contacts?name=scott. How can i make documentation of this api using Apipie Gem

  • what's the method do you use for the `create` method ? is it `POST` or `GET` ? – Mahmood Ahmad Aug 25 '20 at 11:24
  • There are four types of parameter: Header, Path, Query and Body. Normally, an API endpoint like this would be a `POST` request, and the parameters go in the `body`. Not query parameters. – Tom Lord Aug 25 '20 at 11:35

0 Answers0