Questions tagged [grape-api]

Grape is a Ruby Gem that provides a DSL to easily develop RESTful APIs.

Grape is a REST-like API micro-framework for Ruby. It’s designed to run on Rack or complement existing web application frameworks such as Rails and Sinatra by providing a simple DSL to easily develop RESTful APIs.

307 questions
3
votes
1 answer

Grape API files in Rails not reloading

In development mode, the Grape API files in our Rails app aren't reloading as they should. We've tried the suggested approach in the Grape README, and referred to what seems to be the key SO post on it (Ruby on Rails 3 - Reload lib directory for…
Masonoise
  • 1,573
  • 3
  • 14
  • 28
3
votes
1 answer

Resolve all ActiveRecord Associations using Grape::Entity (SQL Join)

Question I've been messing with ruby, grape, grape-entity, and activerecord. Everything is going swimmingly however I can't see to get the desired result from grape-entity when using the using keyword for a expose item. My goal is to basically…
abc123
  • 17,855
  • 7
  • 52
  • 82
3
votes
3 answers

Is it possible to filter the params for a request to a Grape API?

If I set up param validation on a Grape API request is it possible to get a hash of just the validated params? desc "My Grape API request handler" params do requires :name optional :description end post do puts params.inspect # has all the…
Mike Hall
  • 107
  • 1
  • 8
3
votes
1 answer

Generate HTML using grape API in rails

I have a requirement where I need to generate/spit out HTML markup from one of my APIs. I am using grape API but cannot find a way to throw out HTML markup. I can specify content-type as text/html and create a HTML markup but is there a better way…
Kush
  • 909
  • 1
  • 8
  • 14
3
votes
1 answer

use rails 4.0 strong parameter in non rails application

I use active-record 4.0 in a grape api application, but as strong parameter only works in rails controller, how do I permit params in a grape api class
Markee
  • 47
  • 6
3
votes
2 answers

Send file to a client using Grape API

I have been doing rails application that used carrierwave for file uploads. How can I send existing file to a client using Grape API? Let's assume that file is in directory "public/uploads/datafile/1/file.txt".
Prostakov
  • 910
  • 1
  • 12
  • 22
3
votes
1 answer

Grape API modify parameter presence error

As you know, you can specify that a parameter is required in a route like so: requires :province, :type => String However, I would like to be able to change the error that is thrown and provide my own error JSON when the parameter is not given. How…
tekknolagi
  • 10,663
  • 24
  • 75
  • 119
3
votes
1 answer

Split Grape API (non-Rails) into different files

I am writing an API in Grape, but it stands alone, with no Rails or Sinatra or anything. I'd like to split the app.rb file into separate files. I have looked at How to split things up in a grape api app?, but that is with Rails. I'm not sure how to…
tekknolagi
  • 10,663
  • 24
  • 75
  • 119
3
votes
1 answer

Add Path / Auto Load Path For Grape API Not Working

I am using Grape to build my API, and according to the documentation, I added the following lines to application.rb so that allapp/api` ruby scripts are added to the path, as well as allowing auto-reload for development mode: config.paths.add…
darksky
  • 20,411
  • 61
  • 165
  • 254
3
votes
4 answers

Trouble mounting multiple Grape APIs in Rails

I have two APIs that I'm trying to mount in my Rails app-- one called 'v1' and another called 'twilio'. Each API will be composed of multiple files, so I want each to have its own folder. Inside my app/api directory, I have 2 folders--'v1' and…
Andrew
  • 2,425
  • 2
  • 24
  • 35
3
votes
2 answers

API-only app in rails with grape?

i have a question regarding Grape for building an API-only rails app. As I read in the github docs, Grape can be mounted as an API for an existing rails app. Is it possible to write a API-only app with it? Am I right, that I don't need rails…
trnc
  • 20,581
  • 21
  • 60
  • 98
2
votes
1 answer

Grape how to set param values dynamically

We have been using grape for a long time. Below is how we set values for a param. params do optional :my_column1, type: Integer, desc: 'some description', values: MyModel1.all.pluck(:id) optional :my_column2, type: Integer, desc: 'some…
Sinscary
  • 652
  • 12
  • 32
2
votes
1 answer

Grape API is removing '+' from string (replacing with blank space)

I have a grape API and as part of a POST request I am passing a string that has a '+' as part of it (it's a phone number). Grape seems to be removing the + and replacing it with a blank space. module V1 class CustomerDetails < Grape::API …
Robert Faldo
  • 401
  • 7
  • 15
2
votes
1 answer

grape-api - Force empty string to set values to null

I am creating an API endpoint which contains a file upload field and a few string fields. My goal is to allow clients to clear values on those string fields, i.e. the DB should persist these values as null. However, due to the fact that the request…
Martin Verdejo
  • 1,229
  • 2
  • 13
  • 24
2
votes
0 answers

Ruby Grape Api multiple routes with single method

I want to accept multiple routes in a single method. resource :mypath do helpers do def mymethod super_duper_stuff end end post do something_else end get do mymethod end resource :subpath post do …
user433342
  • 859
  • 1
  • 7
  • 26