Questions tagged [ruby-grape]

Grape lets you quickly add maven repository dependencies to your classpath OR Grape is a REST-like API micro-framework written in Ruby to sit on top of Rack.

Grape is a framework that allows for quickly defining REST-like interfaces in Ruby. It provides a DSL for defining versioned APIs as a collection of entities mounted on Rack.

385 questions
2
votes
1 answer

Run certain code at RACK server start

We have a decently big Rails app. However, the restful APIs are slow. Hence, we are prototyping to move the API layer outside of Rails. We are currently considering grape (https://github.com/intridea/grape) which will remove ActiveRecord and other…
Pykih
  • 2,769
  • 3
  • 29
  • 38
2
votes
3 answers

access params in rescue_from

I am using grape and I would like to access the request params within the rescue_from: class API < Grape::API rescue_from Grape::Exceptions::ValidationErrors do |e| rack_response({ end ... How can I do that?
Boti
  • 3,275
  • 1
  • 29
  • 54
2
votes
2 answers

Get absolute URL with Grape-Api gem on Rack app

I'm doing an API with grape gem, in one of my services I would like to retrieve the complete URL. For example if the user does request on : api.myapp.com/android/users.json I would like be able to retrieve api.myapp.com/android/users.json or at…
Léo
  • 792
  • 1
  • 7
  • 27
2
votes
3 answers

How to validate mutual exclusivity of params in Grape API (Ruby)

When defining an API using Grape, there is a very convenient way of validating the presence and type of parameters, e.g.: params do requires :param1, type: String optional :param1, type: Integer end However I can't see a convenient way of…
Rene Wooller
  • 1,107
  • 13
  • 22
2
votes
1 answer

Ruby Grape rescue_from :all not rescuing all errors

My Grape app has several error handlers, including lastly: rescue_from :all, backtrace: true do |e| message = { errors: { all: e.message } } rack_response(format_message(message, e.backtrace), 500 ) end But this is not rescuing at least errors…
George Shaw
  • 1,771
  • 1
  • 18
  • 32
2
votes
2 answers

Rails Grape api versioning module structure

I'm trying to implement api versioning, almost the same as I've done here . but i don't seem to get module/folder structure right in rails app, because I get error messages like V1 is not a module /app/api/v1/xml_responses/device.rb:3:in…
Elmor
  • 4,775
  • 6
  • 38
  • 70
2
votes
1 answer

How to group routes in Swagger-UI

I'm using Grape (on Rails 4), Swagger and Swagger-UI to document my Grape API. Now I wonder how to group routes like the Swagger example: http://petstore.swagger.wordnik.com/ Thats how my Swagger-UI currently looks:
Slevin
  • 4,268
  • 12
  • 40
  • 90
2
votes
3 answers

Ruby Grape: json output is escaped

I am working on a sample Ruby / Grape example, and everything works except the json is served escaped. I am brand new too ruby and its frameworks (just 3 days), so sorry if this question is remedial and thhank you in advance I am fairly certain…
akaphenom
  • 6,728
  • 10
  • 59
  • 109
2
votes
2 answers

Grape API and OAuth

I'm working on creating API for my rails application using Grape framework. I'm trying different authentication possibilities. Can someone give a simple example of using OAuth for authentication?
Prostakov
  • 910
  • 1
  • 12
  • 22
2
votes
2 answers

Newrelic via Heroku doesn't receive data from Ruby instance running in Unicorn although preload_app=true

I'm running a ruby app with grape (no rails) on heroku and am using the new relic addon. The app is forked with unicorn. As described here, I integrated this option to my configs. Here's my setup: unicorn.rb: worker_processes 3 preload_app…
1
vote
1 answer

Grape api (rails) - uninitialized constant Endpoints::TodoAPI (NameError)

I'm using grape to create an api in rails. The project is still pretty fresh but I've hit a blocking point so far with my routes. I added an test endpoint to see if my versions were working together and they were my config/routes.rb…
David
  • 13
  • 2
1
vote
1 answer

Grape API malformed parameters

I'm trying to make a post endpoint, with multiple nested parameters but the params are not as expected I have the following parameters definitions for the endpoint: params do requires :p2 do optional :p3 requires :p4, as: :p4_new …
SergiuXG
  • 43
  • 5
1
vote
1 answer

Rails grape swagger Array example value is showing as an object

I have a nested array on my rails grape api. expose( :users, documentation: { type: Array, desc: 'The pickups and deliveries for specific tours' }, using: Fleetdog::Entities::Users ) But when I visit the…
1
vote
0 answers

Mount grape framework in ramaze framework?

Someone help me to mount grape framework... require 'grape' class Api < Grape::API format :json resources :articles do get do {hello: 'hello world!'} end end end Also i wanna to change custom…
aaaa
  • 73
  • 1
  • 6
1
vote
1 answer

How to skip before filter in Grape Rails?

I am using the grape_rails gem to manage the APIs and on my endpoints I have the following: ..api/v4/endpoints/base.rb class Endpoints::V4::Base < Endpoints::Base before { authenticate_with_token! } version 'v4', using: :path mount…
Samuel D.
  • 199
  • 10