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

receive Array of hashes in API call rails

I 'm working on rails app in which I need to receive array of hashes in API call with Grape like. { tournament_id:1 match_id: 10 [ { team_id: 1 score: 10 }, { …
Muhammad Faisal Iqbal
  • 1,796
  • 2
  • 20
  • 43
1
vote
0 answers

Rails Grape API endpoint returning empty

Problem I have a Rails application with a Grape API implementation. For the most part, everything works well. However, I have a peculiar case that an endpoint named cars always serves up an empty string, the code for the get method is never…
HeyZiko
  • 1,660
  • 15
  • 28
1
vote
1 answer

Rails - Array of hashes in Grape API

I'm really a new guy to Rails, in my project I want to submit a JSON string to Grape API. As you can see, my JSON has an user array that contains many objects. How can I define it in my Grape ? Thank you { "users":[ { …
BraveVN
  • 411
  • 5
  • 22
1
vote
0 answers

How to refer rails session from grape api

I try to refer rails session from grape api. I used grape_session library(https://github.com/faber-lotto/grape_session). And I refer same name Rails session parameter from grape api. But session of grape API is null. Do you know why. I configured…
yone
  • 121
  • 1
  • 1
  • 6
1
vote
2 answers

Enable CORS in Grape on Rails

I am using Grape on Rails. Although I am unable to set CORS for it. The rack-cors gem explains how to set it for "Rails" in application.rb. Although does not show how to enable it for Grape on Rails. Any thoughts ?
Prakash Raman
  • 13,319
  • 27
  • 82
  • 132
1
vote
0 answers

GRAPE-ENTITY ARRAYS

I'm using Grape and Grape-Entity library in Ruby on Rails Project to expose my params from backend. Is any possibility to expose two params values in one entity param? My backend json: {value: '1', value_second: '2'}, but i want to get {values:…
Rafonix
  • 159
  • 1
  • 12
1
vote
1 answer

Versioning an unversioned grape API

I'm working on a Rails app that uses grape for its API. Currently, there's a single version of the API that is mounted in the root folder (not v1, as I would like), and I need to start creating v2. The current version is mounted as…
pgb
  • 24,813
  • 12
  • 83
  • 113
1
vote
1 answer

A route for Grape: either a specific string or an of array of string

I want to create a route for the Grape gem so that a route accepts either an array of strings or a single string with a specific pre-defined value. From the documentation it's not clear how to do that. Your suggestions? UPDATE: I want status to be…
user6324692
1
vote
1 answer

How to debug grape api

module Employee class Data < Grape::API resource :employee_data do desc "Description of all employees" get do EmpDatum.all end desc "create a new employee" …
gates
  • 4,465
  • 7
  • 32
  • 60
1
vote
1 answer

User Grape Entity with Arrays

I was wondering whether Grape Entity would work for rendering arrays of hashes, I thought I remebered it worked but somehow I cannot get it to work right now, am I doing some obvious mistake? Here's my Entity: class V1::Entities::Searchresult <…
Tom
  • 3,807
  • 4
  • 33
  • 58
1
vote
0 answers

Migrating Grape API to standard Rails API

I'm looking to migrate from an API that was built in Grape to a straight Rails API. I've been looking for some resources on the best practises to do so and have come up quite empty. I was wondering if anyone has any good resources/tips/tricks or…
sump
  • 506
  • 2
  • 15
1
vote
1 answer

how to write Rspec for a ruby API use Grape

I recently worked on a API service, and I'm using Grape framework, but I don't quite understand how can I write rspec for my API
Thang Le Sy
  • 107
  • 1
  • 4
  • 6
1
vote
1 answer

rails : grape-swagger-rails API request with http instead of https in swagger documentation

The API is hosted on https. When I try to request the API, the request is made to http instead of https which gives error result. Mixed Content: The page at .... ....was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint How to…
Alif Jamaluddin
  • 518
  • 4
  • 17
1
vote
3 answers

Rails .where query not working

I have a table called Toys that has the columns toy_id, company_id, store_id, name and description I am trying to do a query on the table like the following: toys = @company.toys.where("store_id = ? AND (name LIKE ? OR description LIKE ?)",…
Zack Herbert
  • 942
  • 1
  • 16
  • 39
1
vote
1 answer

Array query parameter for Ruby Grape API

Right now my API accepts a request such as ?a[]=x&a[]=y using: params do requires :a, type: Array[String] end My client can only send the query parameter as ?a[0]=x&a[1]=y which Grape does not understand, resulting in 400 (Bad Request). Is it not…
Filuren
  • 661
  • 2
  • 7
  • 19