rails_api_doc 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/rails_api_doc/01 - Singh Saab The Great - DownloadMing.SE.mp3 +0 -0
- data/app/assets/javascripts/rails_api_doc/apis.js +16 -0
- data/app/assets/javascripts/rails_api_doc/application.js +15 -0
- data/app/assets/javascripts/rails_api_doc/jquery-1.3.2.js +19 -0
- data/app/assets/javascripts/rails_api_doc/parameters.js +2 -0
- data/app/assets/javascripts/rails_api_doc/projects.js +2 -0
- data/app/assets/stylesheets/rails_api_doc/apis.css +4 -0
- data/app/assets/stylesheets/rails_api_doc/application.css +8381 -0
- data/app/assets/stylesheets/rails_api_doc/parameters.css +4 -0
- data/app/assets/stylesheets/rails_api_doc/projects.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/rails_api_doc/apis_controller.rb +149 -0
- data/app/controllers/rails_api_doc/application_controller.rb +4 -0
- data/app/controllers/rails_api_doc/parameters_controller.rb +87 -0
- data/app/controllers/rails_api_doc/projects_controller.rb +87 -0
- data/app/helpers/rails_api_doc/apis_helper.rb +29 -0
- data/app/helpers/rails_api_doc/application_helper.rb +4 -0
- data/app/helpers/rails_api_doc/parameters_helper.rb +4 -0
- data/app/helpers/rails_api_doc/projects_helper.rb +4 -0
- data/app/models/rails_api_doc/api.rb +14 -0
- data/app/models/rails_api_doc/failure_response.rb +8 -0
- data/app/models/rails_api_doc/parameter.rb +7 -0
- data/app/models/rails_api_doc/project.rb +7 -0
- data/app/models/rails_api_doc/success_response.rb +8 -0
- data/app/views/layouts/rails_api_doc/application.html.erb +14 -0
- data/app/views/rails_api_doc/apis/_failure_response_fields.html.erb +10 -0
- data/app/views/rails_api_doc/apis/_form.html.erb +66 -0
- data/app/views/rails_api_doc/apis/_parameter_fields.html.erb +17 -0
- data/app/views/rails_api_doc/apis/_success_response_fields.html.erb +10 -0
- data/app/views/rails_api_doc/apis/edit.html.erb +6 -0
- data/app/views/rails_api_doc/apis/index.html.erb +21 -0
- data/app/views/rails_api_doc/apis/new.html.erb +5 -0
- data/app/views/rails_api_doc/apis/show.html.erb +31 -0
- data/app/views/rails_api_doc/parameters/_form.html.erb +33 -0
- data/app/views/rails_api_doc/parameters/edit.html.erb +6 -0
- data/app/views/rails_api_doc/parameters/index.html.erb +29 -0
- data/app/views/rails_api_doc/parameters/new.html.erb +5 -0
- data/app/views/rails_api_doc/parameters/show.html.erb +25 -0
- data/app/views/rails_api_doc/projects/_form.html.erb +25 -0
- data/app/views/rails_api_doc/projects/edit.html.erb +6 -0
- data/app/views/rails_api_doc/projects/index.html.erb +24 -0
- data/app/views/rails_api_doc/projects/new.html.erb +5 -0
- data/app/views/rails_api_doc/projects/show.html.erb +15 -0
- data/config/routes.rb +14 -0
- data/db/migrate/20131026073600_create_rails_api_doc_apis.rb +13 -0
- data/db/migrate/20131026083511_create_rails_api_doc_parameters.rb +12 -0
- data/db/migrate/20131110085503_create_rails_api_doc_success_responses.rb +10 -0
- data/db/migrate/20131117141240_add_column_note_to_rails_api_doc_success_response.rb +5 -0
- data/db/migrate/20131117144700_create_rails_api_doc_failure_responses.rb +11 -0
- data/db/migrate/20131228045156_create_rails_api_doc_projects.rb +10 -0
- data/db/migrate/20131228051342_add_column_project_id_to_rails_api_doc_api.rb +5 -0
- data/lib/rails_api_doc.rb +4 -0
- data/lib/rails_api_doc/engine.rb +6 -0
- data/lib/rails_api_doc/version.rb +3 -0
- data/lib/tasks/rails_api_doc_tasks.rake +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +16 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +8 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/fixtures/rails_api_doc/apis.yml +15 -0
- data/test/fixtures/rails_api_doc/failure_responses.yml +11 -0
- data/test/fixtures/rails_api_doc/parameters.yml +13 -0
- data/test/fixtures/rails_api_doc/projects.yml +9 -0
- data/test/fixtures/rails_api_doc/success_responses.yml +9 -0
- data/test/functional/rails_api_doc/apis_controller_test.rb +51 -0
- data/test/functional/rails_api_doc/parameters_controller_test.rb +51 -0
- data/test/functional/rails_api_doc/projects_controller_test.rb +51 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/rails_api_doc_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/helpers/rails_api_doc/apis_helper_test.rb +6 -0
- data/test/unit/helpers/rails_api_doc/parameters_helper_test.rb +6 -0
- data/test/unit/helpers/rails_api_doc/projects_helper_test.rb +6 -0
- data/test/unit/rails_api_doc/api_test.rb +9 -0
- data/test/unit/rails_api_doc/failure_response_test.rb +9 -0
- data/test/unit/rails_api_doc/parameter_test.rb +9 -0
- data/test/unit/rails_api_doc/project_test.rb +9 -0
- data/test/unit/rails_api_doc/success_response_test.rb +9 -0
- metadata +239 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
module RailsApiDoc
|
2
|
+
class Api < ActiveRecord::Base
|
3
|
+
attr_accessible :api_group, :name, :request_type, :url, :version, :parameters_attributes,
|
4
|
+
:success_responses_attributes, :failure_responses_attributes, :project_id
|
5
|
+
has_many :parameters, :class_name => "RailsApiDoc::Parameter", dependent: :destroy
|
6
|
+
has_many :success_responses, :class_name => "RailsApiDoc::SuccessResponse", dependent: :destroy
|
7
|
+
has_many :failure_responses, :class_name => "RailsApiDoc::FailureResponse", dependent: :destroy
|
8
|
+
belongs_to :project
|
9
|
+
accepts_nested_attributes_for :parameters, :allow_destroy => true, :reject_if => :all_blank
|
10
|
+
accepts_nested_attributes_for :success_responses, :allow_destroy => true, :reject_if => :all_blank
|
11
|
+
accepts_nested_attributes_for :failure_responses, :allow_destroy => true, :reject_if => :all_blank
|
12
|
+
DEFAULT_PAGE_SIZE = 10
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>RailsApiDoc</title>
|
5
|
+
<%= stylesheet_link_tag "rails_api_doc/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "rails_api_doc/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
|
2
|
+
|
3
|
+
<%= form_for [@project, @api] do |f| %>
|
4
|
+
<% if @api.errors.any? %>
|
5
|
+
<div id="error_explanation">
|
6
|
+
<h2><%= pluralize(@api.errors.count, "error") %> prohibited this api from being saved:</h2>
|
7
|
+
|
8
|
+
<ul>
|
9
|
+
<% @api.errors.full_messages.each do |msg| %>
|
10
|
+
<li><%= msg %></li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
<div class="form-fields">
|
16
|
+
<div class="field">
|
17
|
+
<%= f.label :name %><br />
|
18
|
+
<%= f.text_field :name, :required => "true" %>
|
19
|
+
</div>
|
20
|
+
<div class="field">
|
21
|
+
<%= f.label :url %><br />
|
22
|
+
<%= f.text_field :url, :required => "true" %>
|
23
|
+
</div>
|
24
|
+
<div class="field">
|
25
|
+
<%= f.label :version %><br />
|
26
|
+
<%= f.text_field :version, :required => "true" %>
|
27
|
+
</div>
|
28
|
+
<div class="field">
|
29
|
+
<%= f.label :request_type %><br />
|
30
|
+
<%= f.text_field :request_type, :required => "true" %>
|
31
|
+
</div>
|
32
|
+
<div class="field">
|
33
|
+
<%= f.label :api_group %><br />
|
34
|
+
<%= f.text_field :api_group, :required => "true" %>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
<div class="clear"></div>
|
38
|
+
<h1>Parameters</h1>
|
39
|
+
<div class="nested-fields">
|
40
|
+
<%= f.fields_for :parameters do |ff| %>
|
41
|
+
<%= render "parameter_fields", :f => ff %>
|
42
|
+
<% end %>
|
43
|
+
</div>
|
44
|
+
<div class="link-to-add-more"><%= link_to_add_fields "Add More Parameters", f, :parameters %></div>
|
45
|
+
<div class="clear"></div>
|
46
|
+
<h1>Success Response</h1>
|
47
|
+
<div class="success-fields">
|
48
|
+
<%= f.fields_for :success_responses do |ff| %>
|
49
|
+
<%= render "success_response_fields", :f => ff %>
|
50
|
+
<% end %>
|
51
|
+
</div>
|
52
|
+
<div class="link-to-add-more"><%= link_to_add_success_fields "Add More Success Response", f, :success_responses %></div>
|
53
|
+
<div class="clear"></div>
|
54
|
+
<h1>Failure Response</h1>
|
55
|
+
<div class="failure-fields">
|
56
|
+
<%= f.fields_for :failure_responses do |ff| %>
|
57
|
+
<%= render "failure_response_fields", :f => ff %>
|
58
|
+
<% end %>
|
59
|
+
</div>
|
60
|
+
<div class="link-to-add-more"><%= link_to_add_failure_fields "Add More Failure Response", f, :failure_responses %></div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
<div class="actions">
|
63
|
+
<%= f.submit "Create API", :class => "btn create_api_btn" %>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div>
|
2
|
+
<div class="param-field">
|
3
|
+
<%= f.label :name %><br />
|
4
|
+
<%= f.text_field :name %>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<div class="param-field">
|
8
|
+
<%= f.label :param_type %><br />
|
9
|
+
<%= f.text_field :param_type %>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<div class="param-field">
|
13
|
+
<%= f.label :description %><br />
|
14
|
+
<%= f.text_field :note %>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
<br />
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<h3><%= flash[:notice] %></h3>
|
2
|
+
<h1>Listing apis</h1><br />
|
3
|
+
<% @apis.each do |api| %>
|
4
|
+
<h3>API Name : <%= api.name %></h3>
|
5
|
+
<pre class="prettyprint language-html prettyprinted" data-type="get" style="">
|
6
|
+
<code>
|
7
|
+
<span class="pln"><strong>URL: </strong><%= api.url %></span><br />
|
8
|
+
<span class="pln"><strong>Version: </strong><%= api.version %></span><br />
|
9
|
+
<span class="pln"><strong>Request: </strong><%= api.request_type %></span><br />
|
10
|
+
<span class="pln"><strong>API Group: </strong><%= api.api_group %></span><br />
|
11
|
+
<span class="pln link"><%= link_to 'View Details', project_api_path(@project, api) %> | <%= link_to 'Edit', edit_project_api_path(@project, api) %> | <%= link_to 'Destroy', project_api_path(@project, api), method: :delete, data: { confirm: 'Are you sure?' } %></span>
|
12
|
+
</code>
|
13
|
+
</pre>
|
14
|
+
|
15
|
+
<% end %>
|
16
|
+
<br />
|
17
|
+
<%= paginate @apis %>
|
18
|
+
|
19
|
+
<%= link_to 'New Api', new_project_api_path %>|
|
20
|
+
<%= link_to 'Generate Api Doc', project_generate_doc_path %>|
|
21
|
+
<%= link_to 'All Projects', projects_path%>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<br /><h3>This API is Listed under Project - "<%= @api.project.name %>"</h3><br />
|
4
|
+
<h4>API Name : <%= @api.name %></h4>
|
5
|
+
<pre class="prettyprint language-html prettyprinted" data-type="get" style="">
|
6
|
+
<code>
|
7
|
+
<span class="pln"><strong class="green">URL: </strong><%= @api.url %></span><br />
|
8
|
+
<span class="pln"><strong class="green">Version: </strong><%= @api.version %></span><br />
|
9
|
+
<span class="pln"><strong class="green">Request: </strong><%= @api.request_type %></span><br />
|
10
|
+
<span class="pln"><strong class="green">API Group: </strong><%= @api.api_group %></span><br />
|
11
|
+
<span class="pln"><strong class="big-font">Parameters: </strong></span><br />
|
12
|
+
<% @api.parameters.each do |p|%>
|
13
|
+
<span class="pln"><strong class="green">Name: </strong><%= p.name %></span><br />
|
14
|
+
<span class="pln"><strong class="green">Type: </strong><%= p.param_type%></span><br />
|
15
|
+
<span class="pln"><strong class="green">Note: </strong><%= p.note%></span><br />
|
16
|
+
<% end %>
|
17
|
+
<span class="pln"><strong class="big-font">Succes Response: </strong></span><br />
|
18
|
+
<% @api.success_responses.each do |p|%>
|
19
|
+
<span class="pln"><strong class="green">Note: </strong><%= p.note %></span><br />
|
20
|
+
<span class="pln"><strong class="green">Response: </strong></span><%= p.success_structure %><br /><br />
|
21
|
+
<% end %>
|
22
|
+
<span class="pln"><strong class="big-font">Failure Responses: </strong></span><br />
|
23
|
+
<% @api.failure_responses.each do |p|%>
|
24
|
+
<span class="pln"><strong class="green">Note: </strong><%= p.note%></span><br />
|
25
|
+
<span class="pln"><strong class="green">Type: </strong></span><%= p.failure_structure%><br /><br />
|
26
|
+
<% end %>
|
27
|
+
</code>
|
28
|
+
</pre>
|
29
|
+
|
30
|
+
<%= link_to 'Edit', edit_project_api_path(@project, @api) %> |
|
31
|
+
<%= link_to 'Back', project_apis_path(@project) %>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%= form_for(@parameter) do |f| %>
|
2
|
+
<% if @parameter.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@parameter.errors.count, "error") %> prohibited this parameter from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @parameter.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :name %><br />
|
16
|
+
<%= f.text_field :name %>
|
17
|
+
</div>
|
18
|
+
<div class="field">
|
19
|
+
<%= f.label :type %><br />
|
20
|
+
<%= f.text_field :type %>
|
21
|
+
</div>
|
22
|
+
<div class="field">
|
23
|
+
<%= f.label :note %><br />
|
24
|
+
<%= f.text_field :note %>
|
25
|
+
</div>
|
26
|
+
<div class="field">
|
27
|
+
<%= f.label :api_id %><br />
|
28
|
+
<%= f.number_field :api_id %>
|
29
|
+
</div>
|
30
|
+
<div class="actions">
|
31
|
+
<%= f.submit %>
|
32
|
+
</div>
|
33
|
+
<% end %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<h1>Listing parameters</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<th>Name</th>
|
6
|
+
<th>type</th>
|
7
|
+
<th>Note</th>
|
8
|
+
<th>Api</th>
|
9
|
+
<th></th>
|
10
|
+
<th></th>
|
11
|
+
<th></th>
|
12
|
+
</tr>
|
13
|
+
|
14
|
+
<% @parameters.each do |parameter| %>
|
15
|
+
<tr>
|
16
|
+
<td><%= parameter.name %></td>
|
17
|
+
<td><%= parameter.type %></td>
|
18
|
+
<td><%= parameter.note %></td>
|
19
|
+
<td><%= parameter.api_id %></td>
|
20
|
+
<td><%= link_to 'Show', parameter %></td>
|
21
|
+
<td><%= link_to 'Edit', edit_parameter_path(parameter) %></td>
|
22
|
+
<td><%= link_to 'Destroy', parameter, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
23
|
+
</tr>
|
24
|
+
<% end %>
|
25
|
+
</table>
|
26
|
+
|
27
|
+
<br />
|
28
|
+
|
29
|
+
<%= link_to 'New Parameter', new_parameter_path %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<b>Name:</b>
|
5
|
+
<%= @parameter.name %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<b>type:</b>
|
10
|
+
<%= @parameter.type %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<b>Note:</b>
|
15
|
+
<%= @parameter.note %>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<b>Api:</b>
|
20
|
+
<%= @parameter.api_id %>
|
21
|
+
</p>
|
22
|
+
|
23
|
+
|
24
|
+
<%= link_to 'Edit', edit_parameter_path(@parameter) %> |
|
25
|
+
<%= link_to 'Back', parameters_path %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%= form_for(@project) do |f| %>
|
2
|
+
<% if @project.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@project.errors.count, "error") %> prohibited this project from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @project.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :name %><br />
|
16
|
+
<%= f.text_field :name %>
|
17
|
+
</div>
|
18
|
+
<div class="field">
|
19
|
+
<%= f.label :description %><br />
|
20
|
+
<%= f.text_field :description %>
|
21
|
+
</div>
|
22
|
+
<div class="actions">
|
23
|
+
<%= f.submit %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<h1>All Projects</h1>
|
2
|
+
<table class="table table-striped">
|
3
|
+
<tbody>
|
4
|
+
<tr>
|
5
|
+
<th>Name</th>
|
6
|
+
<th>Description</th>
|
7
|
+
<th>Actions</th>
|
8
|
+
</tr>
|
9
|
+
<% @projects.each do |project| %>
|
10
|
+
<tr>
|
11
|
+
<td><span class="label label-success"><%= project.name %></span></td>
|
12
|
+
<td><%= project.description %></td>
|
13
|
+
<td><%= link_to 'Show', project %> | <%= link_to 'Edit', edit_project_path(project) %> |
|
14
|
+
<%= link_to 'Destroy', project, method: :delete, data: { confirm: 'Are you sure?' } %> |
|
15
|
+
<%= link_to 'All Apis', project_apis_path(project)%> |
|
16
|
+
<%= link_to 'New Api', new_project_api_path(project) %> |
|
17
|
+
<% project_name = project.name.gsub(" ", "_")%>
|
18
|
+
<%= link_to 'View Api Doc', "/assets/#{project_name}/doc/index.html", :target => "_blank" if File.directory?("app/assets/projects/#{project_name}/")%></td>
|
19
|
+
</tr>
|
20
|
+
<% end %>
|
21
|
+
</tbody>
|
22
|
+
</table>
|
23
|
+
<br />
|
24
|
+
<%= link_to 'New Project', new_project_path %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<b>Name:</b>
|
5
|
+
<%= @project.name %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<b>Description:</b>
|
10
|
+
<%= @project.description %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
|
14
|
+
<%= link_to 'Edit', edit_project_path(@project) %> |
|
15
|
+
<%= link_to 'Back', projects_path %>
|