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
1
vote
1 answer

Rails, Grape entity. Expose on condition

I have created grape entity: class VehicleDetails < Grape::Entity expose :id expose :name expose :type expose :health, if: {type: 'basis'} end I want to expose :health if current :type is equal to basis. I try to access it by this method: …
Mr.D
  • 7,353
  • 13
  • 60
  • 119
1
vote
1 answer

Grape Rails RSpec test returning 400

I am trying to test my Grape API, but I am receiving a 400 error in my tests, but when I run the action the test is supposed to test, I get a 201 HTTP response as expected. Not sure what is going on here. Below is the specific RSpec test, but you…
maclover7
  • 137
  • 1
  • 11
1
vote
2 answers

Change view template by API version on Grape and Rails

I am building web API with Grape gem on Ruby on Rails 4.1, with their 'version' function. Sample code here. # app/api/api.rb class API < Grape::API prefix 'api' format :json formatter :json, Grape::Formatter::Rabl default_format :json …
xoyip
  • 82
  • 6
1
vote
2 answers

How can I do request tests with Grape Entity?

The response body is return the "formated json with Grape Entity", but the first_prefered is returning the complete object (json format). How Can I convert the first_prefered object just to get the exposed fields using grape…
Ivan Santos
  • 626
  • 2
  • 7
  • 19
1
vote
1 answer

Configuring Warden with Grape API application

I have configured Warden in my Rails/Grape API app in config/initializers/warden.rb: Rails.application.config.middleware.use Warden::Manager do |manager| manager.default_strategies :password end (I'd share the password strategy code, but it…
Chris Peters
  • 17,918
  • 6
  • 49
  • 65
1
vote
0 answers

How to run multiple Rack::Handler::WEBrick in one Sinatra/Grape file

Basically I have multiple API applications in one Sinatra / GrapeAPI file require 'sinatra' require 'grape' require 'webrick' require 'webrick/https' require 'openssl' CERT_PATH = '/opt/myCA/server/' class WebApp < Sinatra::Base post '/' do …
equivalent8
  • 13,754
  • 8
  • 81
  • 109
1
vote
1 answer

Inherit ApplicationController into Grape-API

I am working in a Rails 3 application. I have few important implementations (like setting tenant id, authentication, etc) in the ApplicationController (as before filter) class of my application. Now when I try to implement API using the Grape, I am…
Pratheeswaran.R
  • 894
  • 1
  • 10
  • 22
1
vote
1 answer

Serialize payload into a grape entity on post/put

Is there a way with Grape & Grape-Entity to automatically serialize data into an entity? It seems like all of the examples use params[:var] (from: https://github.com/intridea/grape) desc "Create a status." params do requires :status, type: String,…
Prescott
  • 7,312
  • 5
  • 49
  • 70
1
vote
1 answer

Grape rspec upload

I create an api in my rails application with grape. Now i want to test all of my api. In my api, i can upload sound, get sound/:id and delete sound/:id. I start to write test for post sound but my test all time return "undefined method [] for…
1
vote
1 answer

Grape API group parameter not working

I want to create a post method in grape where i want to collect all the params once currently I am using it like params do requires :id, type: Integer, desc: "post id" requires :title, type: String, desc: "Title" end post do post =…
Nitin Kumar
  • 184
  • 10
1
vote
1 answer

How can I have Grape return error messages in CSV format?

I have a Rails app and I have implemented api using Grape gem. Now, I created a custom error formatter (CSVFormatter) to return error response in CSV format. And, also I have this in my application's v2.rb file: error_formatter :csv,…
K M Rakibul Islam
  • 33,760
  • 12
  • 89
  • 110
1
vote
1 answer

Rails Grape API versioning

I am trying to create a skeleton for a REST API using Rails 4.0.4 and Grape 0.7.0 to behave like this: Calling the API with a specific version: $ curl -H Accept=application/vnd.acme-v1+json http://localhost:3000/api/a “a-v1” $ curl -H…
hector
  • 907
  • 1
  • 9
  • 23
1
vote
0 answers

carrierwave + grape uploading an image from hashie mash

I have a hashie mash with filename, head, name, content-type, type, etc. #
AJcodez
  • 31,780
  • 20
  • 84
  • 118
1
vote
1 answer

Correct response to POST request for long running process

I am trying to code an API which has a long running process to which an end user may make a POST request: POST /things { "some":"json" } The actual creation process can take some time, will often be queued. It might take many minutes. As a result…
Richard Jordan
  • 8,066
  • 3
  • 39
  • 45
1
vote
1 answer

how to send_data or attached file with goliath and grape?

not sure how this is done, but following how's its done in Sinatra wouldn't cut it on Goliath - How can I send binary data from Sinatra?
David
  • 4,235
  • 12
  • 44
  • 52