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

Authenticate active admin user in grape api endpoint

So here are the components of my application admin panel is on myapp.com/admin built with active admin. then I have a dashboard for users at dashboard.myapp.com built with AngularJs and then I have api built with grape at myapp.com/api. I have a…
Aitizazk
  • 332
  • 1
  • 4
  • 16
3
votes
0 answers

How to include subdirectories to autoload for Grape API?

I'm using Grape to build an API for a Rails project (I'm mounting the grape project in rails routes.rb something like mount Backend::Base => '/'). The files structure is something like: ├── app │   ├── api │   │   └── backend │   │   ├──…
Eki Eqbal
  • 5,779
  • 9
  • 47
  • 81
3
votes
1 answer

Is it possible to give optional URL parameter in grape route

Is it possible to give optional URL parameter in grape route. Ie. for a an endpoint like : get '/user/:name/:location/:id' do end Is there any way to hit this endpoint with or without "location" parameter in the URL. I tried defining…
Hridya
  • 236
  • 2
  • 12
3
votes
1 answer

Grape api - How to POST nested resources?

So, I have this system Im working on using rails 4 and Grape Api. Basically it aggregates information about maintenance services executed on vehicles. My models are defined like this: # service.rb class Service < ActiveRecord::Base has_many…
Fabiano Arruda
  • 648
  • 7
  • 21
3
votes
1 answer

Wisper and Grape return results from a POST request

I have a simple POST Grape endpoint with Wisper pub/sub in a background: module Something class Doit < Grape::API post :now do service = SomePub.new service.subscribe(SomeSub.new) service.call(params) end end end Here…
There Are Four Lights
  • 1,406
  • 3
  • 19
  • 35
3
votes
1 answer

Grape custom error with status code

Hi I am working on rails project right now with Grape Basically I wanna make a custom error with grape since its supported. I have managed to create the custom error, something like this module API module ErrorFormatter def self.call(message,…
kilua
  • 711
  • 1
  • 9
  • 16
3
votes
1 answer

Options grape representer

I am working on a rails API with Representers, using the following gems: Grape, Roar and Grape-Roar Now, I try to add conditions to include (or not include) certain properties in my representer based on a condition I pass from my API endpoint as…
PSR
  • 513
  • 6
  • 16
3
votes
0 answers

ActiveRecord and non-blocking Postgres

I'm wanting to use Grape, Goliath and ActiveRecord to build a non-blocking API in Ruby. The problem I'm running into is there seems to be nothing happening on the EM/Postgres async front. Any activity seems to have stopped around 2012. The only…
anthonator
  • 4,915
  • 7
  • 36
  • 50
3
votes
2 answers

Ember.js POST requests return 400 from the server (Grape API) but are stored successfully into local storage

I've been trying to get a simple Ember.js application to post to a Grape API backend for hours now, but I cannot seem to get it to work. I know the API works because I can post new records to it through the Swagger documentation, and they are…
3
votes
2 answers

Grape Swagger describe JSON body

I'm sending JSON request for most of the POST requests and I embed the JSON in the request body. How can I describe this using grape swagger ?
Jani
  • 1,400
  • 17
  • 36
3
votes
1 answer

Where to place Grape custom validations in Rails 4

I have a Rails 4 project which uses Grape for API stuff, I want to do some custom validations as described in the grape documentation. I want to know where should I place my custom validations code (like in lib file) and will I need to include or…
androidharry
  • 197
  • 1
  • 12
3
votes
1 answer

Not understanding nested resources using the Grape API gem in Rails

Here is what my API looks like: module ServiceRequests class API < Grape::API version 'v1', using: :path format :json namespace :companies do params do requires :company_id, type: Integer, desc: "A Company Id" …
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
3
votes
1 answer

Checking request body in Grape API

I have a line like this in my Grape endpoint to check the contents of the POST body, to provide a testing endpoint: return 'OK' if request.body.string == 'TEST' In my development environment on my laptop, this works just fine. In our staging and…
Masonoise
  • 1,573
  • 3
  • 14
  • 28
3
votes
2 answers

Cant set custom header params with rspec and Grape

I use Grape api and i need to write a test with custom header my code: it "should accept message" do post "/api/v1/my/route", post_data, secret: "ASDFGHJKL" last_response.status.should == 201 end but the route gets no headers at all, i…
Dima
  • 8,586
  • 4
  • 28
  • 57
3
votes
1 answer

How to sanitize grape params

I want to mass update attributes of an entity. How can I sanitize properly the params which is coming from grape? This is my console log about the parameters: params.except(:route_info, :token, :id) => {"display_number"=>"7"} [18]…
Boti
  • 3,275
  • 1
  • 29
  • 54