Setting Rails Grape API
Grape is a REST-like API 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.
Setting project with grape
Adding necessary gems for grape :-
gem 'grape', '~> 1.0', '>= 1.0.3'
gem 'grape-swagger', '~> 0.30.1'
gem 'grape-swagger-rails', '~> 0.3.0'
gem 'rack-cors', :require=>'rack/cors'
Grape is a REST-like API framework for Ruby. It's designed to run on Rack or complement existing web application…
Table of Contents The grape-swagger gem provides an autogenerated documentation for your Grape API. The generated…
Swagger UI as Rails Engine for grape-swagger gem. Contribute to ruby-grape/grape-swagger-rails development by creating…
Rack::Cors provides support for Cross-Origin Resource Sharing (CORS) for Rack compatible web applications. The CORS…
config.middleware.insert_before 0, Rack::Cors do
resource '*', :headers=>:any, :methods=>[:get, :post, :delete, :options]
ActiveSupport::Inflector.inflections(:en) do |inflect|
mount VersioningGrape::API => '/api'
mount GrapeSwaggerRails::Engine => '/swagger'
for rails 6
- app/assets/config/manifest.js :- Adding following lines of code.
//= link grape_swagger_rails/application.css
//= link grape_swagger_rails/application.js