Giter Club home page Giter Club logo

api_taster's Introduction

api_taster's People

Contributors

bitdeli-chef avatar bongole avatar dmasur avatar dmitrytrager avatar dxg avatar emilmelnikov avatar felipeelias avatar fredwu avatar ignu avatar ivobenedito avatar jgarber avatar jtomaszewski avatar mariochavez avatar splattael avatar timurvafin avatar vast avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api_taster's Issues

0.7的bug

在route里定义了

if Rails.env.development?
  ApiTaster.global_params = {
    :version    => 1,
    :auth_token => 'teGpfbVitpnUwm7qStf9'
  }
  ApiTaster.routes do
    desc 'Get a __list__ of reservations'
    get '/reservations'

  end
end

但是在api taster左侧出不来RESERVATIONS
换回0.6.0问题解决

HTML forms for API params

Why not provide a form for API params rather than forcing them to be defined in routes using ApiTaster.routes ?

Circular dependency Rails 4.0

When attempting to use this gem, I keep receiving a circular dependency error originating first in the Application Helper, then moving to the Routes Controller. I believe the dependency is coming from Redcarpet, but I am not 100% sure. Is there any known work around or am I using the gem improperly?

=> Booting Thin
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.1 codename Death Proof)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop

Started GET "/api_taster" for 10.211.55.2 at 2013-10-31 23:10:30 +0100
ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"

RuntimeError (Circular dependency detected while autoloading constant APITaster::ApplicationHelper):
activesupport (4.0.0) lib/active_support/dependencies.rb:460:in load_missing_constant' activesupport (4.0.0) lib/active_support/dependencies.rb:183:inconst_missing'
activesupport (4.0.0) lib/active_support/inflector/methods.rb:228:in const_get' activesupport (4.0.0) lib/active_support/inflector/methods.rb:228:inblock in constantize'
activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in each' activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:ininject'
activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in constantize' activesupport (4.0.0) lib/active_support/core_ext/string/inflections.rb:66:inconstantize'
actionpack (4.0.0) lib/abstract_controller/helpers.rb:139:in block in modules_for_helpers' actionpack (4.0.0) lib/abstract_controller/helpers.rb:130:inmap!'
actionpack (4.0.0) lib/abstract_controller/helpers.rb:130:in modules_for_helpers' actionpack (4.0.0) lib/action_controller/metal/helpers.rb:89:inmodules_for_helpers'
actionpack (4.0.0) lib/abstract_controller/helpers.rb:94:in helper' actionpack (4.0.0) lib/abstract_controller/helpers.rb:171:indefault_helper_module!'
actionpack (4.0.0) lib/abstract_controller/helpers.rb:22:in block in inherited' actionpack (4.0.0) lib/abstract_controller/helpers.rb:22:inclass_eval'
actionpack (4.0.0) lib/abstract_controller/helpers.rb:22:in inherited' actionpack (4.0.0) lib/action_controller/metal/params_wrapper.rb:226:ininherited'
actionpack (4.0.0) lib/abstract_controller/railties/routes_helpers.rb:7:in block (2 levels) in with' actionpack (4.0.0) lib/action_controller/railties/helpers.rb:5:ininherited'
/opt/ruby/lib/ruby/gems/2.0.0/bundler/gems/api_taster-751ec7872a9d/app/controllers/api_taster/application_controller.rb:2:in <module:ApiTaster>' /opt/ruby/lib/ruby/gems/2.0.0/bundler/gems/api_taster-751ec7872a9d/app/controllers/api_taster/application_controller.rb:1:in<top (required)>'
activesupport (4.0.0) lib/active_support/dependencies.rb:423:in load' activesupport (4.0.0) lib/active_support/dependencies.rb:423:inblock in load_file'
activesupport (4.0.0) lib/active_support/dependencies.rb:615:in new_constants_in' activesupport (4.0.0) lib/active_support/dependencies.rb:422:inload_file'
activesupport (4.0.0) lib/active_support/dependencies.rb:323:in require_or_load' activesupport (4.0.0) lib/active_support/dependencies.rb:462:inload_missing_constant'
activesupport (4.0.0) lib/active_support/dependencies.rb:183:in const_missing' /opt/ruby/lib/ruby/gems/2.0.0/bundler/gems/api_taster-751ec7872a9d/app/controllers/api_taster/routes_controller.rb:2:inmodule:ApiTaster'
/opt/ruby/lib/ruby/gems/2.0.0/bundler/gems/api_taster-751ec7872a9d/app/controllers/api_taster/routes_controller.rb:1:in <top (required)>' activesupport (4.0.0) lib/active_support/dependencies.rb:423:inload'
activesupport (4.0.0) lib/active_support/dependencies.rb:423:in block in load_file' activesupport (4.0.0) lib/active_support/dependencies.rb:615:innew_constants_in'
activesupport (4.0.0) lib/active_support/dependencies.rb:422:in load_file' activesupport (4.0.0) lib/active_support/dependencies.rb:323:inrequire_or_load'
activesupport (4.0.0) lib/active_support/dependencies.rb:462:in load_missing_constant' activesupport (4.0.0) lib/active_support/dependencies.rb:183:inconst_missing'
activesupport (4.0.0) lib/active_support/inflector/methods.rb:228:in const_get' activesupport (4.0.0) lib/active_support/inflector/methods.rb:228:inblock in constantize'
activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in each' activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:ininject'
activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in constantize' activesupport (4.0.0) lib/active_support/dependencies.rb:534:inget'
activesupport (4.0.0) lib/active_support/dependencies.rb:565:in constantize' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:76:incontroller_reference'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:66:in controller' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:44:incall'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in block in call' actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:ineach'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in call' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:incall'
railties (4.0.0) lib/rails/engine.rb:511:in call' railties (4.0.0) lib/rails/railtie/configurable.rb:30:inmethod_missing'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in block in call' actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:ineach'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in call' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:incall'
warden (1.2.3) lib/warden/manager.rb:35:in block in call' warden (1.2.3) lib/warden/manager.rb:34:incatch'
warden (1.2.3) lib/warden/manager.rb:34:in call' rack (1.5.2) lib/rack/etag.rb:23:incall'
rack (1.5.2) lib/rack/conditionalget.rb:25:in call' rack (1.5.2) lib/rack/head.rb:11:incall'
remotipart (1.2.1) lib/remotipart/middleware.rb:27:in call' actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:incall'
actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241:in call' rack (1.5.2) lib/rack/session/abstract/id.rb:225:incontext'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in call' actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:incall'
activerecord (4.0.0) lib/active_record/query_cache.rb:36:in call' activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:incall'
activerecord (4.0.0) lib/active_record/migration.rb:369:in call' actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call'
activesupport (4.0.0) lib/active_support/callbacks.rb:373:in _run__3704263887153659769__call__callbacks' activesupport (4.0.0) lib/active_support/callbacks.rb:80:inrun_callbacks'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in call' actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:incall'
actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in call' actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:incall'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' railties (4.0.0) lib/rails/rack/logger.rb:38:incall_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in block in call' activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:inblock in tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in tagged' activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:intagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in call' actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:incall'
rack (1.5.2) lib/rack/methodoverride.rb:21:in call' rack (1.5.2) lib/rack/runtime.rb:17:incall'
activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in call' actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:incall'
railties (4.0.0) lib/rails/engine.rb:511:in call' railties (4.0.0) lib/rails/application.rb:97:incall'
rack (1.5.2) lib/rack/content_length.rb:14:in call' thin (1.6.1) lib/thin/connection.rb:82:inblock in pre_process'
thin (1.6.1) lib/thin/connection.rb:80:in catch' thin (1.6.1) lib/thin/connection.rb:80:inpre_process'
thin (1.6.1) lib/thin/connection.rb:55:in process' thin (1.6.1) lib/thin/connection.rb:41:inreceive_data'
eventmachine (1.0.3) lib/eventmachine.rb:187:in run_machine' eventmachine (1.0.3) lib/eventmachine.rb:187:inrun'
thin (1.6.1) lib/thin/backends/base.rb:73:in start' thin (1.6.1) lib/thin/server.rb:162:instart'
rack (1.5.2) lib/rack/handler/thin.rb:16:in run' rack (1.5.2) lib/rack/server.rb:264:instart'
railties (4.0.0) lib/rails/commands/server.rb:84:in start' railties (4.0.0) lib/rails/commands.rb:78:inblock in <top (required)>'
railties (4.0.0) lib/rails/commands.rb:73:in tap' railties (4.0.0) lib/rails/commands.rb:73:in<top (required)>'
bin/rails:4:in require' bin/rails:4:in

'

Rendered /opt/ruby/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.4ms)
Rendered /opt/ruby/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.0ms)
Rendered /opt/ruby/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (14.6ms)
Rendered /opt/ruby/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (46.7ms)

Not properly handling routes that accept multiple actions.

For example, ActiveAdmin sets up its logout route to accept either DELETE or GET, and in "rake routes" it shows up thusly:

               destroy_admin_user_session DELETE|GET /admin/logout(.:format)                                   active_admin/devise/sessions#destroy

Adding the advised line to ApiTaster.routes is syntactically invalid:

delete '/admin/logout', {}

Adding individual lines per action does not satisfy the missing-routes indication (in fact they just get flagged as obsolete).

Bootstrap error

I'd guess this is a conflict with something in our project, but for what it's worth:

Started GET "/api_taster" for 127.0.0.1 at 2012-06-22 06:11:29 -0500
Processing by ApiTaster::RoutesController#index as HTML
Rendered /Users/mike/.rvm/gems/ruby-1.9.3-p194@tastevin-web/bundler/gems/api_taster-4d0799f5c4d5/app/views/api_taster/routes/_information_warning_li.html.erb (0.7ms)
Rendered /Users/mike/.rvm/gems/ruby-1.9.3-p194@tastevin-web/bundler/gems/api_taster-4d0799f5c4d5/app/views/api_taster/routes/index.html.erb within layouts/api_taster/application (131.7ms)
Completed 500 Internal Server Error in 534ms

ActionView::Template::Error (File to import not found or unreadable: bootstrap.
Load paths:
Sass::Rails::Importer(/Users/mike/.rvm/gems/ruby-1.9.3-p194@tastevin-web/bundler/gems/api_taster-4d0799f5c4d5/app/assets/stylesheets/api_taster/layout.css.scss)
/Volumes/Macintosh HD/Data/Dropbox/railswork/tastevin/tastevin-web/app/assets/stylesheets
/Users/mike/.rvm/gems/ruby-1.9.3-p194@tastevin-web/gems/compass-0.12.1/frameworks/blueprint/stylesheets
/Users/mike/.rvm/gems/ruby-1.9.3-p194@tastevin-web/gems/compass-0.12.1/frameworks/compass/stylesheets
/Users/mike/.rvm/gems/ruby-1.9.3-p194@tastevin-web/gems/html5-boilerplate-0.3.2/stylesheets
Compass::SpriteImporter
(in /Users/mike/.rvm/gems/ruby-1.9.3-p194@tastevin-web/bundler/gems/api_taster-4d0799f5c4d5/app/assets/stylesheets/api_taster/layout.css.scss)):
2:
3:
4: <title>API Taster</title>
5: <%= stylesheet_link_tag "api_taster/application", :media => "all" %>
6: <%= javascript_include_tag "api_taster/application" %>
7: <%= csrf_meta_tags %>
8:
config/initializers/quiet_assets.rb:6:in `call_with_quiet_assets'

Same error with 0.4.2 and current HEAD.

Passing an array

Is there a way to pass an array to the API? I have this endpoint that accepts a JSON array but I can't seem to get it defined in the API Taster DSL.

post '/profile', { :profile => { :friend_ids => [1, 4, 5] } }

The array defined in the example breaks the DSL, the endpoint doesn't work in the API Taster UI. I tried passing the array as a string and it shows up in the interface but it submits the value as a string off course so the backend rejects it.

Thanks!

Namespace limitation (to /api)

I am about to write an api, but ApiTaster shows me all my existing routes as well. The view is incredibly cluttered already and I haven't even started on the API yet. It would be nice to set a limit to /api only.

Rails 4.1 support

Hi,

I did forked this project from #49 with Rails 4.0 support to add support for Rails 4.1 also I have included a patch from this PR #19

I worked this on my branch rails4 in a way that it may not be compatible with Rails 4.0 but is fairly simple to read support to Rails 4 as well.

I'm using api_taster for my private project but I'm not sure what is the future of it since this repo has been stalled for a while. I'll be more than happy to readd support for Rails 4 and have a PR with my changes if there is someone interested on this.

Best,

display http status code

I think that it will be good to see status code, because sometimes, we want send no data, but only request with status code, for example for destroy action.

Update gem version

Could you update the gem version? RubyGems.org is using the 0.7.0 version from July, which doesn't support Rails 4.

Not working with Rails 4.1 (example repo provided)

See https://github.com/andyw8/api-taster-rails-4

I used the exact configuration from the README and defined resources :users but I still get the message The following route definitions are missing from ApiTaster.routes. followed by a list of all the routes.

Here's the output of rake routes:

$ rake routes
    Prefix Verb   URI Pattern               Controller#Action
     users GET    /users(.:format)          users#index
           POST   /users(.:format)          users#create
  new_user GET    /users/new(.:format)      users#new
 edit_user GET    /users/:id/edit(.:format) users#edit
      user GET    /users/:id(.:format)      users#show
           PATCH  /users/:id(.:format)      users#update
           PUT    /users/:id(.:format)      users#update
           DELETE /users/:id(.:format)      users#destroy
api_taster        /api_taster               ApiTaster::Engine

Routes for ApiTaster::Engine:
 missing_definitions_routes GET  /routes/missing_definitions(.:format)  api_taster/routes#missing_definitions
obsolete_definitions_routes GET  /routes/obsolete_definitions(.:format) api_taster/routes#obsolete_definitions
                     routes GET  /routes(.:format)                      api_taster/routes#index
                      route GET  /routes/:id(.:format)                  api_taster/routes#show
                       root GET  /

License missing from gemspec

Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec
via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Bundler now generates gems with a default 'MIT' license. There is even a License Finder
to help companies ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec.
Including a license in your gemspec is a good practice, in any case.

If you need help choosing a license, github has created a license picker tool

How did I find you?

I'm using a script to collect stats on gems, originally looking for download data, but decided to collect licenses too,
and make issues for gemspecs not specifying a license as a public service :)
So far it's going pretty well.
I've written a blog post about it

Application layout conflict

Hej,

Great gem.

Have a problem with the layout. Looks like the application layout of the Rails app is used instead of the engine layout.

Maybe name spacing of the layout would be solution.

undefined method `source' for "GET":String

I've setup my routes file as you have in the README example (with the exception of changing the mount location--see below), but when I try to visit that, I get the error

undefined method `source' for "GET":String

My mount line (set in routes.rb) is:

mount ApiTaster::Engine => "/console" if Rails.env.development?

Trace shows:

api_taster (0.5.0) lib/api_taster/route.rb:48:in `block in normalise_routes!'
api_taster (0.5.0) lib/api_taster/route.rb:37:in `each'
api_taster (0.5.0) lib/api_taster/route.rb:37:in `normalise_routes!'
api_taster (0.5.0) lib/api_taster/route.rb:20:in `map_routes'
api_taster (0.5.0) app/controllers/api_taster/routes_controller.rb:28:in `map_routes'

Using headers

First, thanks for awesome gem. Great idea!

I just start using it, but I couldn't go that far because my API requires the Accept header with the version of the endpoint.

Someting like:

application/vnd.myapp.v1+json

It also only works in a subdomain (like api.).

Any plans of including this? I'd love to help

TypeError in ApiTaster::RoutesController#index

Hi Fred,

It's probably my fault but I cannot find the reason so maybe you'll have an idea.

If I keep this block empty :

ApiTaster.routes do
end

it runs and fetches all my project's routes without any issue.

When I add somes routes in it like :

ApiTaster.routes do
  get '/api/public/artists'
end

I get a TypeError in ApiTaster::RoutesController#index (can't convert Array into Hash) error when visiting the page. Full stack trace here : https://gist.github.com/ae1dfa2af455c2b8f329

Do you have an idea of a possible reason for that ?

Another question at the same time : as I am trying to use it as a public documentation page for our API, would it be possible to have the api_taster gem in a separate app which calls the endpoint on another hostname ? What do you think ?

Thanks,

Aurels

undefined method `routes' for #<Hash:0x007fd023518b50>

When mounted in a rails isolated engine I get this error.

Stack

api_taster (0.5.0) lib/api_taster/route.rb:43:in `block in normalise_routes!'
journey (1.0.4) lib/journey/routes.rb:28:in `each'
journey (1.0.4) lib/journey/routes.rb:28:in `each'
api_taster (0.5.0) lib/api_taster/route.rb:37:in `normalise_routes!'
api_taster (0.5.0) lib/api_taster/route.rb:20:in `map_routes'
api_taster (0.5.0) app/controllers/api_taster/routes_controller.rb:28:in `map_routes'
activesupport (3.2.2) lib/active_support/callbacks.rb:429:in `_run__4001414811447523732__process_action__3753406942727699495__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.2) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
activerecord (3.2.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.2) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.2) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.2) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `dispatch'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:30:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:594:in `call'
railties (3.2.2) lib/rails/engine.rb:479:in `call'
railties (3.2.2) lib/rails/railtie/configurable.rb:30:in `method_missing'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:594:in `call'
railties (3.2.2) lib/rails/engine.rb:479:in `call'
railties (3.2.2) lib/rails/railtie/configurable.rb:30:in `method_missing'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:594:in `call'

Without ApiTaster.routes.draw

NoMethodError in ApiTaster::RoutesController#index
undefined method `call' for nil:NilClass

Not really a bug, just an inconvenience if I want to test if the tool is up and running, but have not thought about test data yet.

customization/configuration

I'd like to be able to customize the following stuff :

  • the name on the top left;
  • the app name on the top right;
  • enable/disable "missing definitions" section.

Have you thought about that Fred ? I'm OK to do that in my fork ;-)

Support bootstrap-sass 3.2

Projects using Bootstrap will typically be using v3 or greater now. Could the gemspec be updated to allow for that?

JS error when loading api_taster

I can't get any useful output out of api_taster at all. I can load ApiTaster just fine, but I don't get the split view like in the screenshot but a separate page. Configuration is pretty much copied from the README.

Screenshot

Uncaught TypeError: Object [object Object] has no method 'popover' bootstrap.js:4
(anonymous function) bootstrap.js:4
jQuery.Callbacks.fire jquery.js:1076
jQuery.Callbacks.self.fireWith jquery.js:1194
jQuery.extend.ready jquery.js:436
DOMContentLoaded jquery.js:950

after clicking "Submit"

GET http://localhost:3000/customers/:customer_id/subscriber_lists/:id?utf8=%E2%9C%93&%5Bapi_taster_url_params%5Dcustomer_id=3&%5Bapi_taster_url_params%5Did=1&%5B%5Dversion=1&%5B%5Dauth_token=teGpfbVitpnUwm7qStf9 404 (Not Found) jquery.js:8241
jQuery.ajaxTransport.send jquery.js:8241
jQuery.extend.ajax jquery.js:7720
$.rails.rails.ajax jquery_ujs.js:99
$.rails.rails.handleRemote jquery_ujs.js:158
(anonymous function) jquery_ujs.js:348
jQuery.event.dispatch jquery.js:3333
jQuery.event.add.elemData.handle.eventHandle

Tested on latest Safari, Chrome, Firefox on OS X

gem 'api_taster', '0.4.7'
gem 'rails', '3.2.6'
ruby 1.9.3p233 (2012-05-30 revision 35845) [x86_64-darwin11.4.0]

CSS/JS wont load

The CSS/JS wont load, I get this error, am I missing any configuration??

ActionController::RoutingError (No route matches [GET] "/stylesheets/api_taster/application.css"):

ActionController::RoutingError (No route matches [GET] "/javascripts/api_taster/application.js"):

This is a API (Rails v3.2.6) only application, so dont have app/assets folder.

Update -

So I looked at this (449eeb6) and followed the instructions and still no luck, here's my updated Gemfile

group :development do
  gem 'api_taster'
  gem 'sprockets'
  gem 'jquery-rails'
  gem 'bootstrap-sass'
end

Header params

This one is kind of a deal breaker to me, I got api_taster working and like it, but I also want to version and authenticate my api using headers.

curl http://localhost:3000/api/products -H 'Authorization: Token token="c576f0136149a2e2d9127b3901015545"'

As seen in:
http://railscasts.com/episodes/350-rest-api-versioning
http://railscasts.com/episodes/352-securing-an-api

This goes beyond the global_params features. For now it's back to postman, let me know if you plan on adding this feature.

Nested resources wrong request URL

I have few nested resources:

  scope module: :api do
    namespace :v1, defaults: { format: 'json' } do
      resources :interviews,   only: %w(index create update show) do
        resources :candidates, only: :create
        resources :questions,  only: %w(create update destroy)
      end
    end
  end

In case of question update route (/v1/interviews/:interview_id/questions/:id) api_taster does ignore interview_id and setup the default value ("1") I defined in API route:

  ApiTaster.routes do
    put  '/v1/interviews/:interview_id/questions/:id',     { interview_id: '1', id: '1'}
  end

When I'm going to change interview_id through the form there is default value remains, see the html

<form class="well form-horizontal" method="post" data-remote="true" action="/v1/interviews/1/questions/:id" accept-charset="UTF-8">

Not properly handling mounted rack components.

Get this:

undefined method `routes' for #<Hash:0x007ff3f479cc10>

When I have this in my routes:

mount Resque::Server => '/admin/resque'

Only happens for some mounts, such as the Sinatra-based Resque::Server (but not my Grape 0.1.5 API, oddly).

Non-resource routes don't display

Rails 3.2.6, Ruby 1.9.3, latest API-taster.
It seems that only resources can be added to the ApiTaster.routes block, but custom-routes (match) don't display in the sidebar. It also doesn't allow me to include them manually. Any ideas?

undefined method `routes' for #<Sinatra::ShowExceptions:0xb449750>

Hi,

I followed the instructions to use api_taster, but when running rake routes, I'm getting this error:

rake aborted!
undefined method routes' for #<Sinatra::ShowExceptions:0xb449750> /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/api_taster-0.3.0/lib/api_taster/route.rb:17:inblock in routes'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/journey-1.0.3/lib/journey/routes.rb:28:in each' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/journey-1.0.3/lib/journey/routes.rb:28:ineach'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/api_taster-0.3.0/lib/api_taster/route.rb:12:in routes' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/api_taster-0.3.0/lib/api_taster/route.rb:39:infind_by_verb_and_path'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/api_taster-0.3.0/lib/api_taster/mapper.rb:23:in map_method' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/api_taster-0.3.0/lib/api_taster/mapper.rb:9:inpost'
/home/saas/workspace/emkt-3/config/routes.rb:288:in block (2 levels) in <top (required)>' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/api_taster-0.3.0/lib/api_taster.rb:12:ininstance_eval'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/api_taster-0.3.0/lib/api_taster.rb:12:in routes' /home/saas/workspace/emkt-3/config/routes.rb:285:inblock in <top (required)>'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/actionpack-3.2.2/lib/action_dispatch/routing/route_set.rb:276:in instance_exec' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/actionpack-3.2.2/lib/action_dispatch/routing/route_set.rb:276:ineval_block'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/actionpack-3.2.2/lib/action_dispatch/routing/route_set.rb:254:in draw' /home/saas/workspace/emkt-3/config/routes.rb:3:in<top (required)>'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:245:in load' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:245:inblock in load'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:236:in load_dependency' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:245:inload'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:40:in block in load_paths' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:40:ineach'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:40:in load_paths' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:16:inreload!'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:26:in block in updater' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/activesupport-3.2.2/lib/active_support/file_update_checker.rb:78:incall'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/activesupport-3.2.2/lib/active_support/file_update_checker.rb:78:in execute' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:27:inupdater'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:9:in rescue in execute_if_updated' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:7:inexecute_if_updated'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/application/finisher.rb:66:in block in <module:Finisher>' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/initializable.rb:30:ininstance_exec'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/initializable.rb:30:in run' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/initializable.rb:55:inblock in run_initializers'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/initializable.rb:54:in each' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/initializable.rb:54:inrun_initializers'
/home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/application.rb:136:in initialize!' /home/saas/.rvm/gems/ruby-1.9.3-p194-fast/gems/railties-3.2.2/lib/rails/railtie/configurable.rb:30:inmethod_missing'
/home/saas/workspace/emkt-3/config/environment.rb:5:in `<top (required)>'

Am I doing something wrong?

I want ignore some routes

In one application I have API and also simple html pages. So, I want ignore routes for the html pages. Can I do this with api_taster?

Getting routes within devise_scope

I am using devise to handle authentication.
Routes within devise_scope are not detected by api_taster in my Rails routes file.
any advise on how to make api_taster working with this case ?

I had a brief look at Rails routes,
Rails.application.routes.routes returns the routes with the following constraint:
@constraints=[#<Proc:0x007fa54c0dfd88@ .../gems/devise-2.1.2/lib/devise/rails/routes.rb:338 (lambda)>]

how does api_taster work on parsing the routes.rb file ?

the spec draft should be something like this

    it "should ignore unknown routes DSL" do
      routes = ActionDispatch::Routing::RouteSet.new
      routes.draw do
        devise_scope do
          get 'scoped_route' => 'scoped#route'
        end
      end
      Rails.application.stub(:routes).and_return(routes)
      Route.map_routes

      expected_route = [{:id=>1, :name=>"scoped_route", :verb=>"GET", :path=>"/scoped_route", :reqs=>{:action=>"route", :controller=>"scoped"}}]
      Route.missing_definitions.should == expected_route
    end

Update for 2.1.x

Doesn't work with current Bootstrap version. I am using: bootstrap-sass (2.1.0.1)

In Gemfile:
    api_taster (>= 0) ruby depends on
    bootstrap-sass (~> 2.0.3) ruby

Can't get started

I can't get api_taster to run. I can only see Warning Missing Definitions Detected

I didn't define any routes at first, and only added

App::Application.routes.draw do
  mount ApiTaster::Engine => "/api_taster" if Rails.env.development?
end

then I defined routes

App::Application.routes.draw do
  mount ApiTaster::Engine => "/api_taster" if Rails.env.development?

  if Rails.env.development?
    ApiTaster.routes do
      desc 'Get a __list__ of users'
      get '/users'
    end
  end
end

Still both cases it doesn't work, so i tried outside routes.rb

App::Application.routes.draw do
  mount ApiTaster::Engine => "/api_taster" if Rails.env.development?
end

if Rails.env.development?
    ApiTaster.routes do
      desc 'Get a __list__ of users'
      get '/users'
    end
end

Is there anything i'm missing? I'm using rails 4 btw. Also i'm using api-versions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.