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 Netflix fast_jsonapi to pick serializer automatically

I using grape for apis with fast_jsonapi and What I see that I have to always provide serializer name like CompanySerializer.new(Company.all).serializable_hash wondering if it can auto pick serialzier name depending upon resource name or object…
Muhammad Faisal Iqbal
  • 1,796
  • 2
  • 20
  • 43
1
vote
1 answer

Table dosen't exists while setting up new application with grape mounted application

I have mounted grape gem over exsting application & in kept grape api related changes in app >> controller >> api directory. (which is auto loaded. No code is written for autoloading) And in that I have code like fetching values form the database…
Akash Kinwad
  • 704
  • 2
  • 7
  • 22
1
vote
1 answer

Sorcery methods are not available in RESTFULL web services grapes file rails 4

How can i access rails sorcery methods in my RESTFULL API File. desc 'Signin' post "signin_api" do if @user = User.authenticate(params[:email], params[:password]) @user.set_authentication_token @current_user = User.find(@user) …
1
vote
1 answer

The api_key isn't set when calling api via Swagger UI

I am using Swagger UI to generate api doc and want to call api in this page for grape api. I set the security_definitions as below: add_swagger_documentation( hide_documentation_path: true, doc_version: '18.0', mount_path: '/api_doc', …
李梦驰
  • 59
  • 3
1
vote
1 answer

Why do not working grape api for aws sns confirmation?

I am use Grape for create API and use AWS SNS, at the moment I want send request for confirmation but my API code is not executed. The request is sent (I'm looking at the logs), but the code does not work. However it's work via POSTMAN. Found an…
1
vote
0 answers

How to allow top-level JSON array param in Ruby Grape

I have a route with /coordinates. I want to receive a JSON Array on this route, such as: [ {"latitude": 1, "longitude": 1}, {"latitude": 1, "longitude": 2}, {"latitude": 1, "longitude": 3} ] How do I configure the params to parse this…
1
vote
1 answer

Limit parameter in get request not working in Rails 5 Grape Api

I built my first api and it works as expected, but I am having a hard time understanding why I can't limit the results in my request. All the searches I've seen on the subject list the limit param the same as I have it listed below. My api is…
Charles Smith
  • 3,201
  • 4
  • 36
  • 80
1
vote
1 answer

Return nested array with Ruby Grape in Rails 5

I have successfully built an api as you can see here and the code is below. I need to list the objects as a nested array and not an array of objects, but I cannot figure it out. api/v1/plaques.rb module API module V1 class Plaques <…
Charles Smith
  • 3,201
  • 4
  • 36
  • 80
1
vote
2 answers

How to create two routes in one block in grape?

I want to catch 2 similar route in one action block. In Rails5 I can do that easily. I first declare this: get ':folder/:file' => 'get#index', :file => /.*/, :folder => /.*/ get ':file' => 'get#index', :file => /.*/ This allows me to catch :folder…
Dennis
  • 1,805
  • 3
  • 22
  • 41
1
vote
1 answer

How to generate PDF in Rails 5 Grape API endpoint and send in response?

I am using rails 5 and grape gem for building my application. Now I have a requirement of generating a PDF and send back to the response using grape endpoint. I am using wicked_pdf gem and wkhtmltopdf-binary for generate PDF. But I am facing the…
hgsongra
  • 1,454
  • 15
  • 25
1
vote
0 answers

Unable to use tags in swagger documentation

I had my API looking great in Swagger like this: desc 'blah', tags: ['User Management'] All my API calls were well grouped with the 'tags'. However, I needed to change the 'desc' line to include a necessary header paramater: desc 'blah' do …
pirhac
  • 887
  • 2
  • 8
  • 16
1
vote
1 answer

Grape - Do not apply validator on optional parameter

I'm having an issue for an API written with the Grape gem. I've written a custom validator that checks that UUIDs sent to my API match the expected format. For optional fields, users can either 1. not send the value, or 2. send a null value. And in…
Pierre-Adrien
  • 2,836
  • 29
  • 30
1
vote
2 answers

Grape: custom validator for each element of an array

Is it possible to run a custom validator against each element of array in Grape? I know I can validate whole array with my validator, but I think error messages would be better if I use it for each element. My parameters look like this: …
katafrakt
  • 2,438
  • 15
  • 19
1
vote
0 answers

How to use nested exposure when referencing the same model twice?

I have a grape entity for a Contact model, which references User model twice: class Contact < ApplicationRecord belongs_to :user, foreign_key: :user_id belongs_to :contact, class_name: 'User', foreign_key: :contact_id def entity …
1
vote
1 answer

Grape stand alone rest api ERROR: No application configured, nothing to run

I have followed this tutorial step by step: https://wildandcrazytutorials.wordpress.com/2016/03/05/how-to-build-a-grape-standalone-rest-api/ However I get the error: Puma starting in single mode... Version 3.6.2 (ruby 2.2.2-p95), codename: Sleepy…
Amanda Cavallaro
  • 303
  • 3
  • 18