syedmusamah / grape_on_rails_routes Goto Github PK
View Code? Open in Web Editor NEWSee Rails-like routes for Grape API's mounted on Rails
License: MIT License
See Rails-like routes for Grape API's mounted on Rails
License: MIT License
Ruby: 2.4.0
Rails: 5.0.1 (4 as well)
Routes.rb
Rails.application.routes.draw do
mount API => '/api'
end
API
class V1::V0::BoxWeightEstimatorApi < Grape::API
get '/something' do
{foo: :bar}
end
end
Terminal
GET | /:version/something(.:format) | v1.0 |
* | /?*path(.:format) | |
I recently updated my bundle dependencies and now I get some warnings when I run rake grape:routes.
$ rake grape:routes
~/.rvm/gems/ruby-2.3.0/gems/grape_on_rails_routes-0.2.0/lib/tasks/grape.rake:17: The route_xxx methods such as route_method have been deprecated, please use request_method.
~/.rvm/gems/ruby-2.3.0/gems/grape_on_rails_routes-0.2.0/lib/tasks/grape.rake:18: The route_xxx methods such as route_path have been deprecated, please use path.
~/.rvm/gems/ruby-2.3.0/gems/grape_on_rails_routes-0.2.0/lib/tasks/grape.rake:19: The route_xxx methods such as route_version have been deprecated, please use version.
~/.rvm/gems/ruby-2.3.0/gems/grape_on_rails_routes-0.2.0/lib/tasks/grape.rake:20: The route_xxx methods such as route_description have been deprecated, please use description.
~/.rvm/gems/ruby-2.3.0/gems/grape_on_rails_routes-0.2.0/lib/tasks/grape.rake:8: The route_xxx methods such as route_method have been deprecated, please use request_method.
~/.rvm/gems/ruby-2.3.0/gems/grape_on_rails_routes-0.2.0/lib/tasks/grape.rake:9: The route_xxx methods such as route_path have been deprecated, please use path.
~/.rvm/gems/ruby-2.3.0/gems/grape_on_rails_routes-0.2.0/lib/tasks/grape.rake:10: The route_xxx methods such as route_version have been deprecated, please use version.
~/.rvm/gems/ruby-2.3.0/gems/grape_on_rails_routes-0.2.0/lib/tasks/grape.rake:11: The route_xxx methods such as route_description have been deprecated, please use description.
$ bundler show grape
~/.rvm/gems/ruby-2.3.0/gems/grape-0.16.1
I checked https://rubygems.org/gems/grape/ and they updated grape on April 2nd.
When i execute the command rails grape:routes
, I get te following error:
rails aborted!
NoMethodError: undefined method `routes' for Pipetree::Railway:Class
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/grape_on_rails_routes-0.3.2/lib/tasks/grape.rake:8:in `each'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/grape_on_rails_routes-0.3.2/lib/tasks/grape.rake:8:in `flat_map'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/grape_on_rails_routes-0.3.2/lib/tasks/grape.rake:8:in `block (2 levels) in <main>'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/railties-6.0.0/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/railties-6.0.0/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/railties-6.0.0/lib/rails/command.rb:48:in `invoke'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/railties-6.0.0/lib/rails/commands.rb:18:in `<main>'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require'
/Users/marvintrejo/code/rails/urbano/urbano_express_api/bin/rails:9:in `<top (required)>'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
/Users/marvintrejo/.rvm/gems/ruby-2.6.3@urbano_express_api/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
/Users/marvintrejo/code/rails/urbano/urbano_express_api/bin/spring:15:in `require'
/Users/marvintrejo/code/rails/urbano/urbano_express_api/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => grape:routes
(See full trace by running task with --trace)
my Gemfile:
gem 'devise', '4.7'
gem 'doorkeeper', '5.1'
gem 'grape', '1.2.4'
gem 'grape-middleware-logger', '1.12.0'
gem 'grape-active_model_serializers', '1.5.2'
gem 'grape-swagger', '0.33.0'
gem 'swagger_ui_engine', '1.1.2'
gem 'grape_on_rails_routes', '0.3.2'
gem 'trailblazer', '2.0.7'
gem 'trailblazer-rails', '1.0.11'
gem 'trailblazer-operation', '0.0.13'
gem 'reform', '2.2.4'
gem 'reform-rails', '0.1.7'
gem 'dry-validation', '1.3.1'
Ruby version: 2.6.3
Rails version: 6.0
Any idea? Thank!
According to the gemspec this will not work on rails 5 ? Any plans to change this ?
Hi,
How can I have this functionality integrated in rake routes
?
Thanks in advance
Grape routes look like /api/#{version}/endpoint, however grape on rails routes shows only version and endpoint. As a new-to-grape-user it took me a while to figure out what the actual routes were.
grape_on_rails_routes only advertises a dependency on rails, however it also has a dependency on grape:
grape_klasses = ObjectSpace.each_object(Class).select { |klass| klass < Grape::API }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.