GithubHelp home page GithubHelp logo

apipie / apipie-rails Goto Github PK

View Code? Open in Web Editor NEW
2.5K 2.5K 456.0 2.41 MB

Ruby on Rails API documentation tool

License: Apache License 2.0

Ruby 93.45% JavaScript 0.03% CSS 0.18% HTML 4.57% Jupyter Notebook 1.77%

apipie-rails's People

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  avatar  avatar  avatar  avatar  avatar  avatar

apipie-rails's Issues

Add support for Rails::API

restapi is a nice feature you would like to have when building with Rails::API.

On my attempts I've crossed with a couple of stoppers:

ActiveController::Base references

On lib/restapi/application.rb the resource name will not be resolved correctly.

The error shown is undefined method 'humanize' for nil:NilClass on resource_description.rb:23: 'initialize'.

A possible lazy solution for it would be like this:

    def get_resource_name(klass)
      if klass.class == String
        klass
      elsif klass.class == Class && 
        (
          ActionController::Base.descendants.include?(klass) ||
          ActionController::API.descendants.include?(klass)
        )
        klass.controller_name
      end
    end

The previous override had to be done inside the gem. Apparently running the restapi:static task can't handle a monkey patch as suggested here.

heredoc like expressions

I'm working with Rails 3.2.6, Ruby 1.9.3 and the released gem version of restapi.

The provided examples that include a DOC expressions are not correctly processed. The error that is shown when running the restapi:static task is wrong number of arguments (1 for 0) on restapi_module.rb, line 47.

Example used:

config.app_info < <-DOC
    This is where you can inform user about your application and API
    in general.
 DOC

Update 06/27:

  • Tested with bleeding edge restapi and problems are still the same
  • Added specific message error for ActiveController::Base references

Documentation broken for nested controllers

I have some nested controllers in my app:

namespace :users do
  resource :sessions, only: [:create, :destroy]
end
namespace :sellers do
  resource :sessions, only: [:create, :destroy]
end

The documentation of those controllers is generated as Sessions and the Sellers::SessionsController documentation is overwriting the Users::SessionsController documentation. I added resource_ids for both controllers, this displays both documentations, but the examples are still recorded as sessions#create and not displayed.

generator.rb - dead code?

https://github.com/Pajk/apipie-rails/blob/master/lib/apipie/client/generator.rb seems to be dead code. It references another files, which are not available in repository: https://github.com/Pajk/apipie-rails/blob/master/lib/apipie/client/generator.rb#L8

Also note that the generator.rb uses /bin/env shebang, which might be issue for Fedora, that's where came my interest in this file ;)

[1] https://lists.fedoraproject.org/pipermail/devel/2013-July/185797.html

Add params_like :method

Now there is 'see :method' available in DSL, it maybe does make sense to use it in few cases but much more helpful feature would be the possibility to say 'method A has same parameters as method B'. Almost every #update method has same params as #create method.

Possible solution:

api :PUT, '/resource'
params_like :create
def update; end

When asking for #update parameters description, apipie would take those from #create method.

NoMethodError in Apipie::ApipiesController#index

Hi,

Everytime apipie metadata (api :GET "method", etc.. ) is in a controller method a get the error "undefined method `first' for nil:NilClass" when I try to run http://localhost:3000/apidoc.
Also the development environment becomes unstable.
Same error "undefined method 'first'" occurs when I run the app "rails s" or when I run tests with "rspec".

Everything comes back to normal if I remove apipie metadata from controllers. However the generated documentation contains only basic information about the project only.

Is it a bug or am I doing something wrong ?

Some System Configurations:

ruby 1.9.2
rails 3.2.2
mongoid 2.4.8
device 2.0.4
rspec 2.8.0

FULL STACK TRACE BELOW:

NoMethodError in Apipie::ApipiesController#index

undefined method `first' for nil:NilClass
Rails.root: /home/brbuild/Repository/atcloud-trunk-code/atcloud-desktop/backend/atcloud-services

Application Trace | Framework Trace | Full Trace
/home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:110:in block in visit_Psych_Nodes_Sequence' /home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:109:ineach'
/home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:109:in visit_Psych_Nodes_Sequence' /home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/visitor.rb:8:inaccept'
/home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:16:in accept' /home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:116:inblock in visit_Psych_Nodes_Sequence'
/home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:116:in each' /home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:116:invisit_Psych_Nodes_Sequence'
/home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/visitor.rb:8:in accept' /home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:16:inaccept'
/home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:110:in block in visit_Psych_Nodes_Sequence' /home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:109:ineach'
/home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:109:in visit_Psych_Nodes_Sequence' /home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/visitor.rb:8:inaccept'
/home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:16:in accept' /home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/nodes/node.rb:25:into_ruby'
/home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:107:in load' /home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:205:inload_file'
apipie-rails (0.0.13) lib/apipie/application.rb:162:in recorded_examples' apipie-rails (0.0.13) lib/apipie/apipie_module.rb:17:inmethod_missing'
apipie-rails (0.0.13) lib/apipie/method_description.rb:145:in load_recorded_examples' apipie-rails (0.0.13) lib/apipie/method_description.rb:42:ininitialize'
apipie-rails (0.0.13) lib/apipie/application.rb:33:in new' apipie-rails (0.0.13) lib/apipie/application.rb:33:indefine_method_description'
apipie-rails (0.0.13) lib/apipie/apipie_module.rb:17:in method_missing' apipie-rails (0.0.13) lib/apipie/dsl_definition.rb:114:inmethod_added'
app/controllers/users_controller.rb:56:in <class:UsersController>' app/controllers/users_controller.rb:4:in<top (required)>'
activesupport (3.2.2) lib/active_support/dependencies.rb:469:in load' activesupport (3.2.2) lib/active_support/dependencies.rb:469:inblock in load_file'
activesupport (3.2.2) lib/active_support/dependencies.rb:639:in new_constants_in' activesupport (3.2.2) lib/active_support/dependencies.rb:468:inload_file'
activesupport (3.2.2) lib/active_support/dependencies.rb:353:in require_or_load' activesupport (3.2.2) lib/active_support/dependencies.rb:502:inload_missing_constant'
activesupport (3.2.2) lib/active_support/dependencies.rb:192:in block in const_missing' activesupport (3.2.2) lib/active_support/dependencies.rb:190:ineach'
activesupport (3.2.2) lib/active_support/dependencies.rb:190:in const_missing' activesupport (3.2.2) lib/active_support/inflector/methods.rb:229:inblock in constantize'
activesupport (3.2.2) lib/active_support/inflector/methods.rb:228:in each' activesupport (3.2.2) lib/active_support/inflector/methods.rb:228:inconstantize'
activesupport (3.2.2) lib/active_support/core_ext/string/inflections.rb:54:in constantize' apipie-rails (0.0.13) lib/apipie/application.rb:228:inload_controller_from_file'
apipie-rails (0.0.13) lib/apipie/application.rb:205:in block in reload_documentation' apipie-rails (0.0.13) lib/apipie/application.rb:204:ineach'
apipie-rails (0.0.13) lib/apipie/application.rb:204:in reload_documentation' apipie-rails (0.0.13) lib/apipie/apipie_module.rb:17:inmethod_missing'
apipie-rails (0.0.13) app/controllers/apipie/apipies_controller.rb:35:in block in index' actionpack (3.2.2) lib/action_controller/metal/mime_responds.rb:278:incall'
actionpack (3.2.2) lib/action_controller/metal/mime_responds.rb:278:in retrieve_collector_from_mimes' actionpack (3.2.2) lib/action_controller/metal/mime_responds.rb:194:inrespond_to'
apipie-rails (0.0.13) app/controllers/apipie/apipies_controller.rb:6:in index' actionpack (3.2.2) lib/action_controller/metal/implicit_render.rb:4:insend_action'
actionpack (3.2.2) lib/abstract_controller/base.rb:167:in process_action' actionpack (3.2.2) lib/action_controller/metal/rendering.rb:10:inprocess_action'
actionpack (3.2.2) lib/abstract_controller/callbacks.rb:18:in block in process_action' activesupport (3.2.2) lib/active_support/callbacks.rb:403:in_run__289530229__process_action__981829134__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:inprocess_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:inblock 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:ininstrument'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in instrument' actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:29:inprocess_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:inprocess_action'
actionpack (3.2.2) lib/abstract_controller/base.rb:121:in process' actionpack (3.2.2) lib/abstract_controller/rendering.rb:45:inprocess'
actionpack (3.2.2) lib/action_controller/metal.rb:203:in dispatch' actionpack (3.2.2) lib/action_controller/metal/rack_delegation.rb:14:indispatch'
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:incall'
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:incall'
journey (1.0.3) lib/journey/router.rb:68:in block in call' journey (1.0.3) lib/journey/router.rb:56:ineach'
journey (1.0.3) lib/journey/router.rb:56:in call' actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:594:incall'
apipie-rails (0.0.13) lib/apipie/static_dispatcher.rb:57:in call' mongoid (2.4.8) lib/rack/mongoid/middleware/identity_map.rb:33:inblock in call'
mongoid (2.4.8) lib/mongoid.rb:133:in unit_of_work' mongoid (2.4.8) lib/rack/mongoid/middleware/identity_map.rb:33:incall'
warden (1.1.1) lib/warden/manager.rb:35:in block in call' warden (1.1.1) lib/warden/manager.rb:34:incatch'
warden (1.1.1) lib/warden/manager.rb:34:in call' actionpack (3.2.2) lib/action_dispatch/middleware/best_standards_support.rb:17:incall'
rack (1.4.1) lib/rack/etag.rb:23:in call' rack (1.4.1) lib/rack/conditionalget.rb:25:incall'
actionpack (3.2.2) lib/action_dispatch/middleware/head.rb:14:in call' actionpack (3.2.2) lib/action_dispatch/middleware/params_parser.rb:21:incall'
actionpack (3.2.2) lib/action_dispatch/middleware/flash.rb:242:in call' rack (1.4.1) lib/rack/session/abstract/id.rb:205:incontext'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in call' actionpack (3.2.2) lib/action_dispatch/middleware/cookies.rb:338:incall'
activerecord (3.2.2) lib/active_record/query_cache.rb:64:in call' activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:incall'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:28:in block in call' activesupport (3.2.2) lib/active_support/callbacks.rb:405:in_run__278193939__call__820555053__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_call_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:27:incall'
actionpack (3.2.2) lib/action_dispatch/middleware/reloader.rb:65:in call' actionpack (3.2.2) lib/action_dispatch/middleware/remote_ip.rb:31:incall'
actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:16:in call' actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:incall'
railties (3.2.2) lib/rails/rack/logger.rb:26:in call_app' railties (3.2.2) lib/rails/rack/logger.rb:16:incall'
actionpack (3.2.2) lib/action_dispatch/middleware/request_id.rb:22:in call' rack (1.4.1) lib/rack/methodoverride.rb:21:incall'
rack (1.4.1) lib/rack/runtime.rb:17:in call' activesupport (3.2.2) lib/active_support/cache/strategy/local_cache.rb:72:incall'
rack (1.4.1) lib/rack/lock.rb:15:in call' actionpack (3.2.2) lib/action_dispatch/middleware/static.rb:61:incall'
railties (3.2.2) lib/rails/engine.rb:479:in call' railties (3.2.2) lib/rails/application.rb:220:incall'
rack (1.4.1) lib/rack/content_length.rb:14:in call' railties (3.2.2) lib/rails/rack/log_tailer.rb:14:incall'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in service' /home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:inservice'
/home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in run' /home/brbuild/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:inblock in start_thread'
Request

Parameters:

None
Show session dump

Show env dump

GATEWAY_INTERFACE: "CGI/1.1"
HTTP_ACCEPT: "text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"
HTTP_ACCEPT_CHARSET: "ISO-8859-1,utf-8;q=0.7,*;q=0.3"
HTTP_ACCEPT_ENCODING: "gzip,deflate,sdch"
HTTP_ACCEPT_LANGUAGE: "en-US,en;q=0.8"
HTTP_CACHE_CONTROL: "no-cache"
HTTP_PRAGMA: "no-cache"
REMOTE_ADDR: "16.127.74.34"
REMOTE_HOST: "hmarchezi.americas.hpqcorp.net"
SERVER_NAME: "16.127.74.251"
SERVER_PROTOCOL: "HTTP/1.1"
Response

Headers:

None

Dependencies are not properly installed in non-dev environments

The gemspec has:
s.add_development_dependency "maruku"
s.add_development_dependency "RedCloth"

But a bundle install --without development (for example on Heroku) results in:
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- maruku (LoadError)

My app won't start without explicitly adding these to my Gemfile. Please fix the dependencies.

View overrides for apipie:static task

Hi.
As far as I could see, there is no way to override views when generating static documentation.

It works fine over the web, but not for static docs.

We solved it by copying all views to our app and overwriting renderer method in task definition.

I'm guessing that it should work just by changing renderer method to look in Rails.root views also?

Execution error when loggin rake tasks

This is how we log all rake tasks:

module Rake
  include Log4r

  LOG = Logger.new('rake task')
  LOG.level = DEBUG
  file = FileOutputter.new('fileOutputter', :filename => 'log/rake_tasks.log',:trunc => false)
  file.formatter = PatternFormatter.new(:pattern => "%p [%l]\t%d (%C)\t:: %.1200m") # Format: PID [LEVEL] DATE (LOGGER_NAME) :: Message
  LOG.add file

  class Task
    alias_method :origin_invoke, :invoke if method_defined?(:invoke)

    def invoke(*args)
      LOG.info "#{name} -- #{args.inspect}"
      origin_invoke(args)
    end
  end
end

Unfortunatly the static API generation via the command:

bundle exec rake apipie:static --trace

then trows the following error:

** Invoke apipie:static (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute apipie:static
rake aborted!
undefined method `[]' for nil:NilClass
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/apipie-rails-0.0.22/app/views/apipie/apipies/index.html.erb:2:in `__home_USER__rvm_gems_ruby_______p____project_gems_apipie_rails________app_views_apipie_apipies_index_html_erb___1697847984224691063_94050580'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/actionpack-3.2.13/lib/action_view/template.rb:145:in `block in render'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/activesupport-3.2.13/lib/active_support/notifications.rb:125:in `instrument'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/actionpack-3.2.13/lib/action_view/template.rb:143:in `render'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/actionpack-3.2.13/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `block in instrument'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `instrument'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/actionpack-3.2.13/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:46:in `block in render_template'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:45:in `render_template'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:18:in `render'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/actionpack-3.2.13/lib/action_view/renderer/renderer.rb:36:in `render_template'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/actionpack-3.2.13/lib/action_view/renderer/renderer.rb:17:in `render'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/actionpack-3.2.13/lib/action_view/helpers/rendering_helper.rb:24:in `render'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/haml-4.0.3/lib/haml/helpers/action_view_mods.rb:12:in `render_with_haml'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/apipie-rails-0.0.22/lib/tasks/apipie.rake:71:in `block in render_page'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/apipie-rails-0.0.22/lib/tasks/apipie.rake:67:in `open'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/apipie-rails-0.0.22/lib/tasks/apipie.rake:67:in `render_page'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/apipie-rails-0.0.22/lib/tasks/apipie.rake:92:in `generate_index_page'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/apipie-rails-0.0.22/lib/tasks/apipie.rake:30:in `block (3 levels) in '
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/apipie-rails-0.0.22/lib/tasks/apipie.rake:128:in `with_loaded_documentation'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/apipie-rails-0.0.22/lib/tasks/apipie.rake:20:in `block (2 levels) in '
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/home/USER/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/home/USER/workspace_sti/project/project-core/config/application.rb:92:in `invoke'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/gems/rake-10.1.0/bin/rake:33:in `'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/bin/rake:23:in `load'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/bin/rake:23:in `'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/bin/ruby_noexec_wrapper:14:in `eval'
/home/USER/.rvm/gems/ruby-2.0.0-p195@project/bin/ruby_noexec_wrapper:14:in `'
Tasks: TOP => apipie:static

So the problem occurs in calling the "origin_invoke(args)" function (see first code snippet). Is this an Apipie issue or something else? All other rake tasks seem to just work fine.

best
p

PS: when I call "origin_invoke" method without the args then Apipie just runs fine.

Handling bad request with cache doesn't work correctly

The new way of handling cache is

render_from_cache and return

but render_from_cache() ends with

ensure
      Apipie.request_script_name = nil
end

which means it always returns nil and therefore the return statement of

render_from_cache and return

is never triggered

Segfault on Mac

03:38:12 web.1     | Started GET "/apidoc" for 127.0.0.1 at 2012-06-28 03:38:12 -0500
03:38:12 web.1     | Processing by Restapi::RestapisController#index as HTML
03:38:12 web.1     | /Users/krainboltgreene/Code/Ruby/manacurve-api/vendor/ruby/1.9.1/gems/restapi-0.0.4/lib/restapi/markup.rb:27: [BUG] Segmentation fault
03:38:12 web.1     | ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
03:38:12 web.1     | -- Control frame information -----------------------------------------------
03:38:12 web.1     | c:0087 p:---- s:0463 b:0463 l:000462 d:000462 CFUNC  :render
03:38:12 web.1     | c:0086 p:0015 s:0459 b:0459 l:000458 d:000458 METHOD /Users/krainboltgreene/Code/Ruby/manacurve-api/vendor/ruby/1.9.1/gems/restapi-0.0.4/lib/restapi/markup.rb:27
03:38:12 web.1     | c:0085 p:0037 s:0455 b:0455 l:000454 d:000454 METHOD /Users/krainboltgreene/Code/Ruby/manacurve-api/vendor/ruby/1.9.1/gems/restapi-0.0.4/lib/restapi/helpers.rb:4
03:38:12 web.1     | c:0084 p:0020 s:0451 b:0451 l:000450 d:000450 METHOD /Users/krainboltgreene/Code/Ruby/manacurve-api/vendor/ruby/1.9.1/gems/restapi-0.0.4/lib/restapi/restapi_module.rb:48

Using redcarpet breaks it I think.

Doesn't Play Well With Some Rspec Stubs

Hello,

I am using 0.0.22 with Rails 3.2.12 and Ruby 1.9.3.

I ran into an odd issue with Rspec stubs.

When using APIPIE_RECORD=examples rake spec:controllers I would get a stack overflow error:

/Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/set.rb:247: stack level too deep (SystemStackError)

All of my specs pass, it just wouldnt record the documentation.

I traced the problem down to this line in one of my before filters before one of the specs:
@file = stub(File, :original_filename => "woo")

For some reason it did not like it. I also tried MANY variations on stub, including doing away with File altogether and just doing stub(:original_filename => "woo"), none of which worked.

Finally i used a struct in place of the stub and it worked:

file = Struct.new(:original_filename)
@file = file.new("woo")

DRY validations with connection to activerecord validators

Being able to expose existing validators from the model to the API documentation thought apipie would be a really neat feature.

Something like:

param :user do
  ar_param :name
end

or

ar_param :user, do
  param :name
end

I'm not decided about how the DSL should look like, but you've got the point:)

Export to markdown

I'm facing the needs of exporting the documentation created with Apipie to be used on pdf documents and other sites and I found that there isn't an export feature.

I used the rake apipie:static to get the html and found that I cannot convert it to markdown with Pandoc.

It would be very useful if you add an export method to create static markdown pages.

A possible template could be this one.

api console

This is a really awesome gem! Thanks for making this!!

One question though, would it be possible to add a feature to generate a WADL file which would help integrate with apigee's console?

Additional Customization possible?

I'm still continuing to look at all of the functionality of apipie, but I think it will be the doc library that we wind up using. I am wondering if you have any suggestions for the following, though.

  1. Is it possible to configure the controller that apipie uses, and have it extend the base one, so you can add your own custom code to the mix?
  2. if not, s it possible to pass your own filters to the existing controller/
  3. If either of these are not๏ฟฝ possible, is it possible to add authentication to the apipie doc directory? Basic http auth mostly. We don't want our doc exposed to the world.
  4. Is it possible to alter the templates without unpacking the gem and altering them in the code base? Perhaps an option to point to the views that it uses. I like the default views, with the exception of the 'examples' part. I like that block to be at the bottom of every page as it is usually the longest.
  5. How do you suggest tracking "what changed with this API call from previous versions" ? I was going to put the changes in the descrption, but do you think it makes more sense to add a method called "changes" to ApiPie, that way an entire changelog could be generated from 1 version to the other?

If none of this is possible and you think they are good features, let me know how you think it should be designed and implemented, and I will try to get to it myself. Thanks again!

APIPIE_RECORD=examples rails s

In the extractor wiki, it says that "it watches requests and responses to your application and generates the documentation from this data"

I ran APIPIE_RECORD=examples rails s, but no documentation was generated. Any ideas?

Joseph

Executable files permissions

Hi,
I'm having few small file permissions issues:

  • should lib/apipie/client/generator.rb really have shebang and be executable? If so, the standard permissions are ideally 755, not 775.
  • same strangely-set permissions apply also to spec/dummy/script/rails.
  • apipie/client/template/bin/bin.rb.tt and apipie/client/template/Rakefile.tt have shebangs, but no executable permissions (should be 755, too).

Could you please fix these?
Thanks.

Resolve parameters names conflicts

Client should handle the situation when parameters with same names are described on different levels (resource,method).

Client should be able to use parameters with names 'username' and 'password', now it clashes with clients builtin authentication.

Using `show_in_doc`

Hello,

I am not sure how to use the show_in_doc option.

My first thought was that it was metadata for an example, like:

    context "With correct credentials", :show_in_doc => true do
      it "Can authenticate" do
        ....
      end
    end

    context "with incorrect credentials", :show_in_doc => false do
      it "Can't authenticate" do
          ....
      end
    end

But this doesn't seems to have any effect.

Can you give an example?

Expected /app/app/controllers/api/v1/base_controller.rb to define Api::V1::BaseController vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:503:in `load_missing_constant'

Just upgraded to 0.0.21 and I'm getting these errors:

Expected /app/app/controllers/api/v1/base_controller.rb to define Api::V1::BaseController
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:503:in `load_missing_constant'

That file is in that exact location and it defined class Api::V1::BaseController < ApplicationController. It was working before the upgrade.

I was thinking maybe a load path change. I have this in the initializer config.api_controllers_matcher = File.join(Rails.root, "app", "controllers", "api", "**","*.rb").

Any ideas?

Include disqus comments at the bottom of pages?

What do you think?

Comments add a lot to various APIs I've used over the years. Easy way for you (the author) to get feedback on them and know what to fix, and also for the community to help each other out when you aren't available.

Disqus's built in moderating/upvoting stuff also helps keep it constructive.

Could probably just be a setting (your disqus username) in the initializer .configure block.

Clarify license

spec file state that license is MIT
your git repo contain files MIT-LICENSE and APACHE-LICENSE-2.0
README.rdoc does not specify license

Can you clarify licensing? Is it only MIT or dual license with APACHEv2?

Output samples

I want to add sample output to my description/example, but I'd like to have this done by rendering the templates I have with a sample object rather than copying and pasting code in. Can you suggest an approach for this? Is there a way to modify the metadata associated with each controller action?

Also: I don't understand the reason why you have avoided using block syntax on the api method... it seems to me that the nicest syntax would be something like this:

api :GET, '/items', 'Get list of items' do
param 'blah'
description 'blah'
end

Was there a specific reason to avoid this?

Thanks! Great gem.

Resource level parameter description

Generated cli client is broken when params are described on resource level.

Try to generate client for dummy application - UsersController contain resource_param Hash description and client is not able to create requests.

./client/bin/test_app-client member index --ausername=hi --apassword=there/home/ppokorny/Projects/rails-restapi/spec/dummy/client/lib/test_app_client/base.rb:19:in `validate_params!': undefined method `keys' for [{"resource_param"=>{"ausername"=>"hi", "apassword"=>"there"}}]:Array (NoMethodError)
    from /home/ppokorny/Projects/rails-restapi/spec/dummy/client/lib/test_app_client/resources/member.rb:16:in `index'
    from /home/ppokorny/Projects/rails-restapi/spec/dummy/client/lib/test_app_client/commands/member.thor:41:in `index'
    from /home/ppokorny/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/thor-0.15.4/lib/thor/task.rb:27:in `run'
    from /home/ppokorny/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/thor-0.15.4/lib/thor/invocation.rb:120:in `invoke_task'
    from /home/ppokorny/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/thor-0.15.4/lib/thor.rb:275:in `dispatch'
    from /home/ppokorny/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/thor-0.15.4/lib/thor/base.rb:425:in `start'
    from ./client/bin/test_app-client:55:in `method_missing'
    from /home/ppokorny/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/thor-0.15.4/lib/thor/task.rb:29:in `run'
    from /home/ppokorny/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/thor-0.15.4/lib/thor/task.rb:126:in `run'
    from /home/ppokorny/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/thor-0.15.4/lib/thor/invocation.rb:120:in `invoke_task'
    from /home/ppokorny/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/thor-0.15.4/lib/thor.rb:275:in `dispatch'
    from ./client/bin/test_app-client:44:in `dispatch'
    from /home/ppokorny/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/thor-0.15.4/lib/thor/base.rb:425:in `start'
    from ./client/bin/test_app-client:106:in `<main>'

0.0.14 version does not work out of the box

 <ul class='breadcrumb'>
   <li class='active'><a href='<%= @doc[:doc_url] %>.html'><%= @doc[:name] %> <%= @doc[:resources].values.first[:version] %></a></li>
   <% if @versions && @versions.size > 1 %>
   <li class='pull-right'>
     <%= @versions.collect { |v| link_to v, Apipie.full_url(v) }.join(' / ').html_safe %>

When i start from scratch i get an error when rendering the template seeing an empty @doc[:resources]

rails new myapp
cd myapp/
rm Gemfile.lock
echo "gem 'apipie-rails'" >> Gemfile
bundle install
rails g apipie:install
bundle exec rails s

http://localhost:3000/apipie throws an error

undefined method `[]' for nil:NilClass
apipie-rails (0.0.14) app/views/apipie/apipies/index.html.erb:2:in `__usr_local_lib_ruby_gems_______gems_apipie_rails________app_views_apipie_apipies_index_html_erb___1825703322417886648_28644160'
actionpack (3.2.8) lib/action_view/template.rb:145:in `block in render'
activesupport (3.2.8) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.8) lib/action_view/template.rb:143:in `render'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
actionpack (3.2.8) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.8) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:46:in `block in render_template'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:45:in `render_template'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:18:in `render'
actionpack (3.2.8) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.8) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:110:in `_render_template'
actionpack (3.2.8) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.8) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.8) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.8) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/usr/local/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
activesupport (3.2.8) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:39:in `render'
apipie-rails (0.0.14) app/controllers/apipie/apipies_controller.rb:39:in `block (2 levels) in index'
actionpack (3.2.8) lib/action_controller/metal/mime_responds.rb:196:in `call'
actionpack (3.2.8) lib/action_controller/metal/mime_responds.rb:196:in `respond_to'
apipie-rails (0.0.14) app/controllers/apipie/apipies_controller.rb:13:in `index'
actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.8) lib/active_support/callbacks.rb:404:in `block in _run__4207854536812724586__process_action__1351487586458980802__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_18'
apipie-rails (0.0.14) app/controllers/apipie/apipies_controller.rb:95:in `set_script_name'
activesupport (3.2.8) lib/active_support/callbacks.rb:214:in `_conditional_callback_around_18'
activesupport (3.2.8) lib/active_support/callbacks.rb:403:in `_run__4207854536812724586__process_action__1351487586458980802__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.8) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:36: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.8) lib/action_dispatch/routing/route_set.rb:600:in `call'
apipie-rails (0.0.14) lib/apipie/static_dispatcher.rb:56:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.4) lib/rack/etag.rb:23:in `call'
rack (1.4.4) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.4) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.4) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/cookies.rb:339:in `call'
activerecord (3.2.8) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `_run__2892894460237298900__call__2920884865152699595__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.4) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.4) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.4) lib/rack/lock.rb:15:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.8) lib/rails/engine.rb:479:in `call'
railties (3.2.8) lib/rails/application.rb:223:in `call'
rack (1.4.4) lib/rack/content_length.rb:14:in `call'
railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.4) lib/rack/handler/webrick.rb:59:in `service'
/usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/usr/local/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

I'm actually unable to migrate documented controllers (working properly in 0.0.13) after changing just "version" to "api_version".

0.0.14 breaks namespaced controllers with :root directed to apipie outside RAILS_ENV=development

Symptom (Reproducible):

  1. Take an existing namespaced API controller, i.e. apps/api/v1/do_something_controller.rb
  2. Lock apipie to version 0.0.13
  3. Ensure :root point to 'apipie/apipies' in route.rb
  4. Browse to application running where RAILS_ENV=production.
  5. Everything works!
  6. Switch to 0.0.14.
  7. Reload and repeat step 4.
  8. Error from Rails. "Expect apps/api/v2/do_something_controller.rb to define Api::V1::DoSomething.

Oddly enough, no problems when running in development.

The "VERSION" tag is also broken, but I expect that was intentional?

Unreadable examples.yml

I generating the examples using:

APIPIE_RECORD=examples bundle exec rspec --order default

Sometimes this produces an unloadable yaml file. If I try to load the file manually it says

undefined method `first' for nil:NilClass

TypeError (can't convert Symbol into Integer)

I have the folowing error in my logs

 Jan 31 06:31:07 XXXX: TypeError (can't convert Symbol into Integer):
Jan 31 06:31:07 XXXX: vendor/bundle/ruby/2.0.0/bundler/gems/apipie-rails-03d009f41246/app/controllers/apipie/apipies_controller.rb:30:in `[]' 
....

Which point to this line : https://github.com/Pajk/apipie-rails/blob/master/app/controllers/apipie/apipies_controller.rb#L30

shouldn't it be

@method = @doc[:methods].first if params[:method].present?

instead of

@method = @resource[:methods].first if params[:method].present?

?

Output folder already exists error

When running rake restapi:static for a second time an error is thrown:

rake aborted!
File /{MY_RAILS_APP_PATH}/doc/apidoc already exists

Namespace pollution

This gem overwrites too many methods in Controller.

One example is action documentation. I think all methods describing action are ought to be enclosed in api method, the same way as params to resource are enclosed in resource_description.

RFE: Introduce see field

For all our update methods, I would introduce new field called :see => "Class#method", :description => "Check out this method blah blah". For those, we could use :see => "create" which would create link with some commentary (default: "Also see XYZ"). Because we use the very same input for those.

Something similar as @see in Javadoc.

More here: https://fedorahosted.org/katello/wiki/APIDocumentationEfforts

Scroll down to the bottom.

Development dependecies should be standard dependecies

in the gemspec, the following bloc

  s.add_development_dependency "rspec-rails"
  s.add_development_dependency "rails", ">= 3.0.10"
  s.add_development_dependency "sqlite3"
  s.add_development_dependency "minitest"
  s.add_development_dependency "maruku"
  s.add_development_dependency "RedCloth"
  s.add_development_dependency "rake"
  s.add_development_dependency "rest-client"
  s.add_development_dependency "oauth"

should be replaced by

  s.add_development_dependency "rspec-rails"
  s.add_dependency "rails", ">= 3.0.10"
  s.add_development_dependency "sqlite3"
  s.add_development_dependency "minitest"
  s.add_dependency "maruku"
  s.add_dependency "RedCloth"
  s.add_development_dependency "rake"
  s.add_dependency "rest-client"
  s.add_dependency "oauth"

since most of those gems are production dependecies and not dev dependecies

Support API versioning

API versioning is supported in branch api_versioning.

Generated client does not support this feature yet. Generator creates identical files for different versions of same resource.

Documenting nested resources that aren't represented by controller methods

I have this pattern a few places in my API.

resources :partners
  resource :reports do
    get :sessions
  end
  resources :apps, :only => :index
end

resources :clients
  resource :reports do
    get :sessions
  end
end

Documenting these instances is a little bit hairy with Apipie right now. In PartnersController, I'll have apipie decorators like this which don't have corresponding methods in the controller.

api :GET, '/partners/reports/sessions', 'Show sessions'
api :GET, 'partners/apps', 'Show apps'

Because they're not decorating a controller method, they get bunched together in the resulting documentation. If I try to define params for each one, the params are all jumbled together, like they're describing the same route.

So I try point at the controller that actually contains the controller method.

api :GET, '/partners/reports/sessions', 'Show sessions'
see 'reports#sessions'

api :GET, 'partners/apps', 'Show apps'
see 'apps#index'

Now I get the RuntimeError 'See' method called twice, presumably for the same reason that params get jumbled together.

Additionally, if there are several method-less api decorators at the bottom of a controller, they'll appear as provided by another next controller (whatever is next in alphabetical order) in the resulting documentation.

Any way to include apipie into my engine and have the docs available in the final app?

I get a namespace error when I visit the mounted apipie url in my app.

engine's routes:

Core::Engine.routes.draw do
  apipie
  # snip
end

application's routes:

Rails.application.routes.draw do
  root to: "game#index"

  mount Core::Engine => "/core"
end

Resulting Routes:

root  /     game#index
core  /core Core::Engine

Routes for Core::Engine:
apipie_apipie GET  /apipie(/:version)(/:resource)(/:method)(.:format) core/apipie/apipies#index {:version=>/[^\/]+/}
# snip

Error:

Routing Error
uninitialized constant Core::Apipie

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.