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
2
votes
0 answers

How to expose associated record using grape entity

Hi I have a model Event and this event has one Setting. e.g class Event < ActiveRecord::Base has_one :setting end class Setting < ActieRecord::Base belongs_to :event end My event entity looks some thing like module Entities class…
2
votes
4 answers

NameError at /events path - Undefined Local Variable or Method

I'm quite new to rails and I'm using grape to build an API rails app. I've been getting this error message after I click on the 'Create Event' button :- NameError at /events undefined local variable or method `event_params' for…
oracle02
  • 55
  • 1
  • 10
2
votes
1 answer

How to use force_ssl with grape?

I am trying to create API using Grape gem for rails, but when I am trying to use force_ssl in my application controller, It gives me error "No function found force_ssl". I know this issue is occurring because Grape removes lot of modules from rails,…
2
votes
1 answer

Why is Ruby Base64 encoding conversion losing data and how I can route around?

I am spinning up a a Rails UI that talks to a Grape API. This is the second instance of this program. The first instance works well. The second instance's Grape API, however, appears to be corrupting data before sending it over the wire. I need the…
Sam
  • 1,205
  • 1
  • 21
  • 39
2
votes
1 answer

rackup grape with environment

I have a grape api that I mount directly using rackup and I would like to use an environment option to specify different url when deploying my api in production or development my config.ru #\-p 4000 -s puma require 'grape' #require all…
scauglog
  • 109
  • 1
  • 2
  • 8
2
votes
1 answer

How to do POST request to Grape REST API using params block compatible with Swagger

I am using grape to build a REST API, I am having some trouble with params options. This is how I do a POST request: # Curl Request # curl -X POST -H "Content-Type:application/json" 0:9292/v1/articles -d '{"title":"hello","body":"world"}' #…
user3995789
  • 3,452
  • 1
  • 19
  • 35
2
votes
2 answers

ForbiddenAttributesError with Grape and ActiveRecord

I have a ruby application using Grape, and it doesn't have rails. class Article < ActiveRecord::Base end class API::Articles < Grape::API post '/articles' do article = Article.create(params[:article]) end end Article.create gives…
user3995789
  • 3,452
  • 1
  • 19
  • 35
2
votes
1 answer

How to extract data from a get request with Ruby Grape

I'm experimenting with grape and Ruby by trying to make a Yo API callback function. I can get simple examples up and running like this . . . resource :loc do get ':loc' do params.to_yaml end end How would I go about…
learnvst
  • 15,455
  • 16
  • 74
  • 121
2
votes
1 answer

Documenting Grape API

I'm building a Grape API and most of my requests are based on JSON payloads and not parameters. I've heard that Swagger is not suitable in this regard. I would appreciate if someone could point out to me how the API can be documented effectively.
Jani
  • 1,400
  • 17
  • 36
2
votes
0 answers

How to mount a grape swagger into mountable engine

I am developing a rails api with grape and I am putting the functionality into a mountable engine. In the engine routes I mount the API: mount API => '/' In the test_app I am mounting the engine: mount XBackend::Engine => "/" The specs are…
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
2 answers

Adding custom key-value pair in json output Grape and Rabl

I am building an API with Rails. The gems I use to build api are Grape and Rabl. I have done a lot of work but now I have to add status flag before all the json response from the api. How could I do this? I have this .rabl file. object…
mgs
  • 404
  • 4
  • 15
2
votes
1 answer

Grape API + Active Record Wrapping Transaction

We have grape API but I wonder if we can wrap it with active record transaction every time we do request. In active record to do transaction, we can do something like this: ActiveRecord::Base.transaction do # do select # do update # do…
rhzs
  • 516
  • 7
  • 24
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

How to use CanCan with Grape?

I wanna use CanCan for authorization in my API. How can I use, for example, the authorize! method from Grape::API module? For now, when I'm trying to use it, it returns me this: undefined method 'authorize!' for #
Vadym Kovalenko
  • 699
  • 1
  • 11
  • 27