apitome 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/app/controllers/apitome/docs_controller.rb +11 -6
- data/app/views/apitome/docs/_example.html.erb +20 -0
- data/app/views/apitome/docs/_response_fields.html.erb +1 -1
- data/app/views/apitome/docs/_route.html.erb +1 -1
- data/app/views/apitome/docs/_status.html.erb +1 -1
- data/app/views/apitome/docs/index.html.erb +2 -2
- data/app/views/apitome/docs/show.html.erb +3 -3
- data/app/views/layouts/apitome/application.html.erb +2 -2
- data/lib/apitome/configuration.rb +7 -2
- data/lib/apitome/version.rb +1 -1
- data/lib/generators/apitome/install/templates/initializer.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efbf3bab00d3066329b5e4e13d06759c955126affdf49134524c53ca598e4cd7
|
4
|
+
data.tar.gz: 17eb4bdfe7ae58f73bc61a60e20e2326e8315c332992b63f43e3c5b28354b968
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50602b8235b8f3f6bc3499526044853f478a353de18d2117e135f749bf76aeb3222283a60613a6dc88a20b8118f15790b5f3a44e8fb7edd0b1b203194f1a77a8
|
7
|
+
data.tar.gz: 5e1c5b4dd2ecdd6db82f120a96ff7132defea2cf9e642acab80272f7821a854cd9b4f78e8e266bdb1a81b015033997073707419a390b4a32d3e44856fc148fbb
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ Apitome
|
|
5
5
|
[](https://travis-ci.org/jejacks0n/apitome)
|
6
6
|
[](https://codeclimate.com/github/jejacks0n/apitome/maintainability)
|
7
7
|
[](https://codeclimate.com/github/jejacks0n/apitome/test_coverage)
|
8
|
-
[](https://opensource.org/licenses/MIT)
|
9
9
|
|
10
10
|
Apitome is a API documentation tool for Rails built on top of the great RSpec DSL included in
|
11
11
|
[rspec_api_documentation](https://github.com/zipmark/rspec_api_documentation) (RAD). It's designed to display the
|
@@ -166,8 +166,8 @@ documentation for each configuration directive. Otherwise you can get a refreshe
|
|
166
166
|
|
167
167
|
## Customization
|
168
168
|
You can put custom views and partials in your own `views/apitome/docs` -- check
|
169
|
-
[here for examples](tree/master/app/views/apitome/docs). You can put any
|
170
|
-
overridden.
|
169
|
+
[here for examples](https://github.com/jejacks0n/apitome/tree/master/app/views/apitome/docs). You can put any
|
170
|
+
partial in your own path and they will be overridden.
|
171
171
|
|
172
172
|
Additional customization can come in the form of providing custom css and javascript. You can do this by creating the
|
173
173
|
files you want (that often times require the default assets in the gem), and then configure Apitome to use those instead
|
@@ -3,7 +3,7 @@ require "open-uri"
|
|
3
3
|
class Apitome::DocsController < Object.const_get(Apitome.configuration.parent_controller)
|
4
4
|
layout Apitome.configuration.layout
|
5
5
|
|
6
|
-
helper_method
|
6
|
+
helper_method(*[
|
7
7
|
:resources,
|
8
8
|
:example,
|
9
9
|
:formatted_body,
|
@@ -13,7 +13,7 @@ class Apitome::DocsController < Object.const_get(Apitome.configuration.parent_co
|
|
13
13
|
:set_example,
|
14
14
|
:id_for,
|
15
15
|
:rendered_markdown
|
16
|
-
]
|
16
|
+
])
|
17
17
|
|
18
18
|
def index
|
19
19
|
end
|
@@ -62,7 +62,7 @@ class Apitome::DocsController < Object.const_get(Apitome.configuration.parent_co
|
|
62
62
|
if Apitome.configuration.remote_url && Apitome.configuration.http_basic_authentication
|
63
63
|
{ http_basic_authentication: Apitome.configuration.http_basic_authentication }
|
64
64
|
else
|
65
|
-
|
65
|
+
nil
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -80,14 +80,19 @@ class Apitome::DocsController < Object.const_get(Apitome.configuration.parent_co
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def formatted_body(body, type)
|
83
|
+
return body if body == " "
|
84
|
+
return body if body == "[binary data]" # see https://github.com/zipmark/rspec_api_documentation/blob/560c3bdc7bd5581e7c223334390221ecfc910be8/lib/rspec_api_documentation/client_base.rb#L88-L96
|
83
85
|
if type =~ /json/ && body.present?
|
84
86
|
JSON.pretty_generate(JSON.parse(body))
|
85
87
|
else
|
86
88
|
body
|
87
89
|
end
|
88
|
-
rescue
|
89
|
-
|
90
|
-
|
90
|
+
rescue => e
|
91
|
+
if Apitome.configuration.formatted_body_error_handler
|
92
|
+
Apitome.configuration.formatted_body_error_handler.call(e, body, type)
|
93
|
+
else
|
94
|
+
raise
|
95
|
+
end
|
91
96
|
end
|
92
97
|
|
93
98
|
def param_headers(params)
|
@@ -8,15 +8,26 @@
|
|
8
8
|
<div id="<%= "request-#{index}" %>">
|
9
9
|
<h3><%= t(:request, scope: :apitome) %></h3>
|
10
10
|
<div class="request">
|
11
|
+
<% begin %>
|
11
12
|
<%= render partial: 'apitome/docs/route', locals: {request: request, index: index} %>
|
12
13
|
<%= render partial: 'apitome/docs/headers', locals: {request: request, index: index, headers: request['request_headers']} %>
|
13
14
|
<%= render partial: 'apitome/docs/query', locals: {request: request, index: index} unless request['request_query_parameters'].empty? %>
|
14
15
|
<%= render partial: 'apitome/docs/body', locals: {request: request, index: index, body: request['request_body'], type: request['request_content_type']} if request['request_body'] %>
|
15
16
|
<%= render partial: 'apitome/docs/curl', locals: {request: request, index: index} if request['curl'] %>
|
17
|
+
<%
|
18
|
+
rescue => e
|
19
|
+
if Apitome.configuration.example_error_handler
|
20
|
+
Apitome.configuration.example_error_handler.call(e, "request", request)
|
21
|
+
else
|
22
|
+
raise
|
23
|
+
end
|
24
|
+
end
|
25
|
+
%>
|
16
26
|
</div>
|
17
27
|
|
18
28
|
<h3><%= t(:response, scope: :apitome) %></h3>
|
19
29
|
<div class="response">
|
30
|
+
<% begin %>
|
20
31
|
<%- if Apitome.configuration.simulated_response %>
|
21
32
|
<%= link_to('Simulated Response', simulated_path(example[:link])) if example[:link].present? %>
|
22
33
|
<%- end %>
|
@@ -24,6 +35,15 @@
|
|
24
35
|
<%= render partial: 'apitome/docs/status', locals: {request: request, index: index} %>
|
25
36
|
<%= render partial: 'apitome/docs/headers', locals: {request: request, index: index, headers: request['response_headers']} %>
|
26
37
|
<%= render partial: 'apitome/docs/body', locals: {request: request, index: index, body: request['response_body'], type: request['response_content_type']} if request['response_body'] %>
|
38
|
+
<%
|
39
|
+
rescue => e
|
40
|
+
if Apitome.configuration.example_error_handler
|
41
|
+
Apitome.configuration.example_error_handler.call(e, "response", request)
|
42
|
+
else
|
43
|
+
raise
|
44
|
+
end
|
45
|
+
end
|
46
|
+
%>
|
27
47
|
</div>
|
28
48
|
</div>
|
29
49
|
<% end %>
|
@@ -6,6 +6,6 @@
|
|
6
6
|
</section>
|
7
7
|
<% end %>
|
8
8
|
<% if Apitome.configuration.single_page %>
|
9
|
-
|
9
|
+
<a href="#top" id="scroll-to-top" class="hidden btn btn-primary">Back to Top</a>
|
10
10
|
<% end %>
|
11
|
-
<%= render
|
11
|
+
<%= render "all_examples" if Apitome.configuration.single_page %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<h1 class="resource-name"><%= example[
|
2
|
-
<%= render partial:
|
3
|
-
<%= render partial:
|
1
|
+
<h1 class="resource-name"><%= example["resource"] %></h1>
|
2
|
+
<%= render partial: "resource_explanation", locals: { explanation: example["resource_explanation"] } if example["resource_explanation"] %>
|
3
|
+
<%= render partial: "example", locals: { example: example.merge!(link: params[:path]) } %>
|
@@ -10,12 +10,12 @@
|
|
10
10
|
<body class="<%= Apitome.configuration.single_page ? "single-page" : "" %>">
|
11
11
|
|
12
12
|
<div class="container">
|
13
|
-
<%= render
|
13
|
+
<%= render "header" %>
|
14
14
|
<div class="container docs-container">
|
15
15
|
<div class="row">
|
16
16
|
<div class="col-md-4">
|
17
17
|
<div id="sidebar" class="sidebar hidden-print" role="complementary">
|
18
|
-
<%= render
|
18
|
+
<%= render "navigation" %>
|
19
19
|
</div>
|
20
20
|
</div>
|
21
21
|
<div class="col-md-8" role="main">
|
@@ -4,7 +4,7 @@ module Apitome
|
|
4
4
|
class Configuration
|
5
5
|
include Singleton
|
6
6
|
|
7
|
-
cattr_accessor
|
7
|
+
cattr_accessor(*[
|
8
8
|
:mount_at,
|
9
9
|
:root,
|
10
10
|
:doc_path,
|
@@ -21,7 +21,9 @@ module Apitome
|
|
21
21
|
:http_basic_authentication,
|
22
22
|
:precompile_assets,
|
23
23
|
:simulated_response,
|
24
|
-
|
24
|
+
:formatted_body_error_handler,
|
25
|
+
:example_error_handler,
|
26
|
+
])
|
25
27
|
|
26
28
|
@@mount_at = "/api/docs"
|
27
29
|
@@root = nil # will default to Rails.root if left unset
|
@@ -39,6 +41,8 @@ module Apitome
|
|
39
41
|
@@http_basic_authentication = nil
|
40
42
|
@@precompile_assets = true
|
41
43
|
@@simulated_response = true
|
44
|
+
@@formatted_body_error_handler = nil
|
45
|
+
@@example_error_handler = nil
|
42
46
|
|
43
47
|
def self.root=(path)
|
44
48
|
@@root = Pathname.new(path.to_s) if path.present?
|
@@ -51,5 +55,6 @@ module Apitome
|
|
51
55
|
def self.configure
|
52
56
|
yield @@configuration
|
53
57
|
end
|
58
|
+
|
54
59
|
singleton_class.send(:alias_method, :setup, :configure)
|
55
60
|
end
|
data/lib/apitome/version.rb
CHANGED
@@ -46,7 +46,7 @@ Apitome.configure do |config|
|
|
46
46
|
|
47
47
|
# You can specify how urls are formatted using a Proc or other callable object. Your proc will be called with a
|
48
48
|
# resource name or link, giving you the opportunity to modify it as necessary for in the documentation url.
|
49
|
-
config.url_formatter = -> (str) { str.gsub(/\.json$/, '').underscore.gsub(/[^
|
49
|
+
config.url_formatter = -> (str) { str.gsub(/\.json$/, '').underscore.gsub(/[^[:word:]]/, '-') }
|
50
50
|
|
51
51
|
# You can setup the docs to be loaded from a remote URL if they are not available in the application environment. This
|
52
52
|
# URL is used as the base location and should be set to where the readme is located. If left nil, local is assumed.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apitome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jejacks0n
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -52,8 +52,8 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description: API documentation
|
56
|
-
output
|
55
|
+
description: Present clean and usable API documentation generated from RSpec API Documentation
|
56
|
+
JSON output.
|
57
57
|
email:
|
58
58
|
- jejacks0n@gmail.com
|
59
59
|
executables: []
|
@@ -183,13 +183,13 @@ homepage: https://github.com/jejacks0n/apitome
|
|
183
183
|
licenses:
|
184
184
|
- MIT
|
185
185
|
metadata: {}
|
186
|
-
post_install_message:
|
186
|
+
post_install_message:
|
187
187
|
rdoc_options: []
|
188
188
|
require_paths:
|
189
189
|
- lib
|
190
190
|
required_ruby_version: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- - "
|
192
|
+
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '2.4'
|
195
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -198,8 +198,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
198
|
- !ruby/object:Gem::Version
|
199
199
|
version: '0'
|
200
200
|
requirements: []
|
201
|
-
rubygems_version: 3.
|
202
|
-
signing_key:
|
201
|
+
rubygems_version: 3.2.3
|
202
|
+
signing_key:
|
203
203
|
specification_version: 4
|
204
204
|
summary: 'Apitome: /iˈpitəmē/ An API documentation reader RSpec API Documentation'
|
205
205
|
test_files: []
|