apipie-rails 0.3.4 → 0.3.5
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 +15 -0
- data/CHANGELOG.md +27 -0
- data/README.rst +18 -11
- data/app/helpers/apipie_helper.rb +1 -0
- data/app/views/apipie/apipies/index.html.erb +3 -0
- data/app/views/apipie/apipies/plain.html.erb +6 -0
- data/app/views/apipie/apipies/resource.html.erb +3 -0
- data/app/views/apipie/apipies/static.html.erb +6 -0
- data/config/locales/es.yml +28 -0
- data/config/locales/pl.yml +29 -0
- data/config/locales/ru.yml +29 -0
- data/config/locales/zh-CN.yml +28 -0
- data/config/locales/zh-TW.yml +28 -0
- data/images/screenshot-1.png +0 -0
- data/images/screenshot-2.png +0 -0
- data/lib/apipie/dsl_definition.rb +9 -1
- data/lib/apipie/extractor/writer.rb +1 -1
- data/lib/apipie/method_description.rb +9 -2
- data/lib/apipie/param_description.rb +13 -5
- data/lib/apipie/version.rb +1 -1
- data/lib/tasks/apipie.rake +3 -3
- data/spec/controllers/users_controller_spec.rb +2 -0
- data/spec/dummy/app/controllers/users_controller.rb +3 -1
- data/spec/lib/extractor/writer_spec.rb +6 -0
- data/spec/lib/param_description_spec.rb +27 -0
- data/spec/lib/rake_spec.rb +4 -1
- metadata +12 -37
- data/spec/dummy/public/javascripts/application.js +0 -2
- data/spec/dummy/public/javascripts/controls.js +0 -965
- data/spec/dummy/public/javascripts/dragdrop.js +0 -974
- data/spec/dummy/public/javascripts/effects.js +0 -1123
- data/spec/dummy/public/javascripts/prototype.js +0 -6001
- data/spec/dummy/public/javascripts/rails.js +0 -202
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTljNTJlOWI1NzIzODJhNDg5MjlhODc4ZmY4OTc4MzY2MzRiNmYzMA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
Nzk2MjA1OGE1MDliZjk3M2IzMTkzZTYzODc3YTY3YWQ0ZDY3OWNmYw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OGFlOWZmOWY3ZjUyZGRkMmZkZGRkYWExMDY3MDJmYTA0NDIyODRlOTZlOTk4
|
10
|
+
ZDQ1NjAxOWU4NWVlOTBjOWZmMjUxNDY0OTg2YWNlMGQ1NTdjMTA0NDFjZTk3
|
11
|
+
NDc1ODQ4MGU4YTFkNjg5YWE2ZmM2N2NjOTY2YzgzMTgwYjA3NzU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Y2ZhMjhlMDY4N2Q1NTE3NmZiOGE0M2FlOGM0ODMxMWQ5NGI3NjRlYTVlM2E5
|
14
|
+
YzU0ZmIyOWI4OWM5NzFhOWJiZWJlYTVmZjliOGYzODY0YmE0MjdhZGE1NTJh
|
15
|
+
MDFlMTFjMTNiMDRiMmI5NDkzOWQ0YTI1ZGYxNmNjYjhjZDU3ZTc=
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,26 @@
|
|
2
2
|
Changelog
|
3
3
|
===========
|
4
4
|
|
5
|
+
v0.3.5
|
6
|
+
------
|
7
|
+
|
8
|
+
* Cleaning up unreachable code
|
9
|
+
[#385](https://github.com/Apipie/apipie-rails/pull/385) [@voxik][]
|
10
|
+
* Russian translation
|
11
|
+
[#352](https://github.com/Apipie/apipie-rails/pull/352) [@Le6ow5k1][]
|
12
|
+
* Ability to hide controller methods from documentation
|
13
|
+
[#356](https://github.com/Apipie/apipie-rails/pull/356) [@davidcollie][]
|
14
|
+
* Use doc_path configuration in rake tasks
|
15
|
+
[#358](https://github.com/Apipie/apipie-rails/pull/358) [@saneshark][]
|
16
|
+
* Chinese translation
|
17
|
+
[#363](https://github.com/Apipie/apipie-rails/pull/363) [@debbbbie][]
|
18
|
+
* Polish translation
|
19
|
+
[#375](https://github.com/Apipie/apipie-rails/pull/375) [@dbackowski][]
|
20
|
+
* Spanish translation
|
21
|
+
[#376](https://github.com/Apipie/apipie-rails/pull/376) [@isseu][]
|
22
|
+
* Add an alternative to action aware required param
|
23
|
+
[#377](https://github.com/Apipie/apipie-rails/pull/377) [@mourad-ifeelgoods][]
|
24
|
+
|
5
25
|
v0.3.4
|
6
26
|
------
|
7
27
|
|
@@ -291,3 +311,10 @@ v0.0.15
|
|
291
311
|
[@iliabylich]: https://github.com/iliabylich
|
292
312
|
[@dadario]: https://github.com/dadario
|
293
313
|
[@saneshark]: https://github.com/saneshark
|
314
|
+
[@voxik]: https://github.com/voxik
|
315
|
+
[@Le6ow5k1]: https://github.com/Le6ow5k1
|
316
|
+
[@davidcollie]: https://github.com/davidcollie
|
317
|
+
[@saneshark]: https://github.com/saneshark
|
318
|
+
[@debbbbie]: https://github.com/debbbbie
|
319
|
+
[@dbackowski]: https://github.com/dbackowski
|
320
|
+
[@isseu]: https://github.com/isseu
|
data/README.rst
CHANGED
@@ -27,11 +27,11 @@ Getting started
|
|
27
27
|
|
28
28
|
The easiest way to get Apipie up and running with your app is:
|
29
29
|
|
30
|
-
.. code::
|
30
|
+
.. code:: sh
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
echo "gem 'apipie-rails'" >> Gemfile
|
33
|
+
bundle install
|
34
|
+
rails g apipie:install
|
35
35
|
|
36
36
|
Now you can start documenting your resources and actions (see
|
37
37
|
`DSL Reference`_ for more info):
|
@@ -56,8 +56,8 @@ features such as generating documentation from tests, recording examples etc.
|
|
56
56
|
Screenshots
|
57
57
|
-----------
|
58
58
|
|
59
|
-
.. image:: https://
|
60
|
-
.. image:: https://
|
59
|
+
.. image:: https://github.com/Apipie/apipie-rails/blob/master/images/screenshot-1.png
|
60
|
+
.. image:: https://github.com/Apipie/apipie-rails/blob/master/images/screenshot-2.png
|
61
61
|
|
62
62
|
Authors
|
63
63
|
-------
|
@@ -224,6 +224,9 @@ see
|
|
224
224
|
meta
|
225
225
|
Hash or array with custom metadata.
|
226
226
|
|
227
|
+
show
|
228
|
+
Resource is hidden from documentation when set to false (true by default)
|
229
|
+
|
227
230
|
Example:
|
228
231
|
~~~~~~~~
|
229
232
|
|
@@ -236,6 +239,7 @@ Example:
|
|
236
239
|
|
237
240
|
# More complex example
|
238
241
|
api :GET, "/users/:id", "Show user profile"
|
242
|
+
show false
|
239
243
|
error :code => 401, :desc => "Unauthorized"
|
240
244
|
error :code => 404, :desc => "Not Found", :meta => {:anything => "you can think of"}
|
241
245
|
param :session, String, :desc => "user is logged in", :required => true
|
@@ -857,8 +861,8 @@ Adding custom validator
|
|
857
861
|
Only basic validators are included but it is really easy to add your own.
|
858
862
|
Create a new initializer with a subclass of Apipie::Validator::BaseValidator.
|
859
863
|
Two methods are required to implement this - instance method
|
860
|
-
|
861
|
-
|
864
|
+
:code:`validate(value)` and class method
|
865
|
+
:code:`build(param_description, argument, options, block)`.
|
862
866
|
|
863
867
|
When searching for the validator +build+ method, every subclass of
|
864
868
|
Apipie::Validator::BaseValidator is called. The first one that returns the
|
@@ -1095,6 +1099,9 @@ When you want to avoid any unnecessary computation in production mode,
|
|
1095
1099
|
you can generate a cache with ``rake apipie:cache`` and configure the
|
1096
1100
|
app to use it in production with ``config.use_cache = Rails.env.production?``
|
1097
1101
|
|
1102
|
+
Default cache dir is ``File.join(Rails.root, "public", "apipie-cache")``,
|
1103
|
+
you can change it to where you want, example: ``config.cache_dir = File.join(Rails.root, "doc", "apidoc")``.
|
1104
|
+
|
1098
1105
|
If, for some complex cases, you need to generate/re-generate just part of the cache
|
1099
1106
|
use ``rake apipie:cache cache_part=index`` resp. ``rake apipie:cache cache_part=resources``
|
1100
1107
|
To generate it for different locations for further processing use ``rake apipie:cache OUT=/tmp/apipie_cache``.
|
@@ -1263,8 +1270,8 @@ further versions.
|
|
1263
1270
|
|
1264
1271
|
There is, however, an even better and more flexible way to reuse your API
|
1265
1272
|
documentation for this purpose: using the API the Apipie
|
1266
|
-
provides in the generator code. Check out
|
1267
|
-
`
|
1273
|
+
provides in the generator code. Check out our sister project
|
1274
|
+
`apipie-bindings <https://github.com/Apipie/apipie-bindings>`_, as they
|
1268
1275
|
use exactly this approach. You also don't need to run the service,
|
1269
1276
|
provided it uses Apipie as a backend.
|
1270
1277
|
|
@@ -1294,4 +1301,4 @@ configuration:
|
|
1294
1301
|
|
1295
1302
|
* `Read-world application usage with versioning <https://github.com/theforeman/foreman>`_
|
1296
1303
|
|
1297
|
-
* `Using Apipie API to generate bindings <https://github.com/
|
1304
|
+
* `Using Apipie API to generate bindings <https://github.com/Apipie/apipie-bindings>`_
|
@@ -2,6 +2,9 @@
|
|
2
2
|
<h4><a href='#<%= key %>'><%= resource[:name] %></a></h4>
|
3
3
|
<ul>
|
4
4
|
<% resource[:methods].each do |method| %>
|
5
|
+
<% if !method[:show] %>
|
6
|
+
<% next %>
|
7
|
+
<% end %>
|
5
8
|
<li><a href='#<%= key %>-<%= method[:name] %>'><%= method[:name] %></a></li>
|
6
9
|
<% end %>
|
7
10
|
</ul>
|
@@ -26,6 +29,9 @@
|
|
26
29
|
<div>
|
27
30
|
|
28
31
|
<% resource[:methods].each do |method| %>
|
32
|
+
<% if !method[:show] %>
|
33
|
+
<% next %>
|
34
|
+
<% end %>
|
29
35
|
<hr/>
|
30
36
|
|
31
37
|
<h3 id="<%= "#{key}-#{method[:name]}" %>">
|
@@ -2,6 +2,9 @@
|
|
2
2
|
<h4><a href='#<%= key %>'><%= resource[:name] %></a></h4>
|
3
3
|
<ul>
|
4
4
|
<% resource[:methods].each do |method| %>
|
5
|
+
<% if !method[:show] %>
|
6
|
+
<% next %>
|
7
|
+
<% end %>
|
5
8
|
<li><a href='#<%= key %>-<%= method[:name] %>'><%= method[:name] %></a></li>
|
6
9
|
<% end %>
|
7
10
|
</ul>
|
@@ -34,6 +37,9 @@
|
|
34
37
|
<div class='accordion' id='accordion'>
|
35
38
|
|
36
39
|
<% resource[:methods].each do |method| %>
|
40
|
+
<% if !method[:show] %>
|
41
|
+
<% next %>
|
42
|
+
<% end %>
|
37
43
|
<hr>
|
38
44
|
|
39
45
|
<ul class='breadcrumb' id='<%= key %>-<%= method[:name] %>'>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
es:
|
2
|
+
apipie:
|
3
|
+
resources: Recursos
|
4
|
+
resource: Recurso
|
5
|
+
description: Descripción
|
6
|
+
no_docs_found: No se encontró la documentación
|
7
|
+
no_docs_found_descr: No hemos encontrado ninguna documentación para tu API.
|
8
|
+
follow_instructions_html: Siga %{href} sobre cómo describir sus controladores.
|
9
|
+
follow_instructions_href: más instrucciones
|
10
|
+
oops: Huy!!
|
11
|
+
resource_not_found_html: Recurso %{res} no encontrado.
|
12
|
+
method_not_found_html: Método %{method} no encontrado para el recurso %{resource}.
|
13
|
+
goto_homepage_html: Trate de ir a %{href}
|
14
|
+
goto_homepage_href: "%{app_name} página de documentación API "
|
15
|
+
required: requerido
|
16
|
+
optional: opcional
|
17
|
+
nil_allowed: nil permitido
|
18
|
+
param_name: Nombre del parámetro
|
19
|
+
params: Parámetros
|
20
|
+
examples: Ejemplos
|
21
|
+
metadata: Metadatos
|
22
|
+
errors: Errores
|
23
|
+
supported_formats: Formatos soportados
|
24
|
+
enable_javascript_html: Por favor, active JavaScript para ver el %{comments_href}.
|
25
|
+
comments_powered_by_disqus: comentarios gracias a %{disqus}
|
26
|
+
api_documentation: Documentación de la API
|
27
|
+
headers: Cabeceras
|
28
|
+
header_name: Nombre de cabecera
|
@@ -0,0 +1,29 @@
|
|
1
|
+
pl:
|
2
|
+
apipie:
|
3
|
+
resources: Zasoby
|
4
|
+
resource: Zasób
|
5
|
+
description: Opis
|
6
|
+
no_docs_found: Nie znalezionio dokumentacji
|
7
|
+
no_docs_found_descr: Nie znaleziono dokumentacji dla twojego API.
|
8
|
+
follow_instructions_html: Przejdź do %{href} aby opisać swoje kontrolery.
|
9
|
+
follow_instructions_href: dalsze instrukcje
|
10
|
+
oops: Ups!!
|
11
|
+
resource_not_found_html: Zasób %{res} nie został znaleziony.
|
12
|
+
method_not_found_html: Metoda %{method} dla zasobu %{resource} nie została znaleziona.
|
13
|
+
goto_homepage_html: Spróbuj przejść do %{href}
|
14
|
+
goto_homepage_href: "%{app_name} Strona główna dokumentacji API"
|
15
|
+
required: wymagany
|
16
|
+
optional: opcjonalny
|
17
|
+
nil_allowed: nil dopuszczalny
|
18
|
+
param_name: Nazwa parametru
|
19
|
+
params: Parametry
|
20
|
+
examples: Przykłady
|
21
|
+
metadata: Metadane
|
22
|
+
errors: Błędy
|
23
|
+
supported_formats: Dostępne formaty
|
24
|
+
enable_javascript_html: Proszę włączyć obsługę javascript w celu zobaczenia %{comments_href}.
|
25
|
+
comments_powered_by_disqus: komentarze obsługiwane przez %{disqus}
|
26
|
+
api_documentation: Dokumentacja API
|
27
|
+
headers: Nagłówki
|
28
|
+
header_name: Nazwa nagłówka
|
29
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
ru:
|
2
|
+
apipie:
|
3
|
+
resources: Ресурсы
|
4
|
+
resource: Ресурс
|
5
|
+
description: Описание
|
6
|
+
no_docs_found: Документация не найдена
|
7
|
+
no_docs_found_descr: Мы не нашли никакой документации для вашего API.
|
8
|
+
follow_instructions_html: Перейдите по ссылке %{href}, чтобы узнать как описать ваш API.
|
9
|
+
follow_instructions_href: дополнительные инструкции
|
10
|
+
oops: Ой!!
|
11
|
+
resource_not_found_html: Ресурс %{res} не найден.
|
12
|
+
method_not_found_html: Метод %{method} для ресурса %{resource} не найден.
|
13
|
+
goto_homepage_html: Перейдите %{href}
|
14
|
+
goto_homepage_href: "%{app_name} домашняя страница API документации"
|
15
|
+
required: обязательно
|
16
|
+
optional: необязательно
|
17
|
+
nil_allowed: nil разрешен
|
18
|
+
param_name: Имя параметра
|
19
|
+
params: Параметры
|
20
|
+
examples: Примеры
|
21
|
+
metadata: Метаданные
|
22
|
+
errors: Ошибки
|
23
|
+
supported_formats: Поддерживаемые форматы
|
24
|
+
enable_javascript_html: Пожалуйста включите JavaScript, чтобы просматривать %{comments_href}.
|
25
|
+
comments_powered_by_disqus: комментарии представлены %{disqus}
|
26
|
+
api_documentation: API документация
|
27
|
+
headers: Заголовки
|
28
|
+
header_name: Название заголовка
|
29
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
'zh-CN':
|
2
|
+
apipie:
|
3
|
+
resources: 资源
|
4
|
+
resource: 资源
|
5
|
+
description: 描述
|
6
|
+
no_docs_found: 没有找到文档
|
7
|
+
no_docs_found_descr: 没有找到文档。
|
8
|
+
follow_instructions_html: 点击 %{href} 查看描述。
|
9
|
+
follow_instructions_href: 高级指导
|
10
|
+
oops: Oops!!
|
11
|
+
resource_not_found_html: 没有找到资源 %{res} 。
|
12
|
+
method_not_found_html: 没有找到资源 %{res} 的方法 %{method} 。
|
13
|
+
goto_homepage_html: 试图访问 %{href}
|
14
|
+
goto_homepage_href: "%{app_name} API 文档主页"
|
15
|
+
required: 必填
|
16
|
+
optional: 选填
|
17
|
+
nil_allowed: 允许空值
|
18
|
+
param_name: 参数名字
|
19
|
+
params: 参数
|
20
|
+
examples: 示例
|
21
|
+
metadata: 元数据
|
22
|
+
errors: 错误
|
23
|
+
supported_formats: 支持格式
|
24
|
+
enable_javascript_html: 浏览 %{comments_href}前请允许执行 JavaScript 。
|
25
|
+
comments_powered_by_disqus: 评论技术支持 %{disqus}
|
26
|
+
api_documentation: API 文档
|
27
|
+
headers: 头部
|
28
|
+
header_name: 头部名字
|
@@ -0,0 +1,28 @@
|
|
1
|
+
'zh-TW':
|
2
|
+
apipie:
|
3
|
+
resources: 資源
|
4
|
+
resource: 資源
|
5
|
+
description: 描述
|
6
|
+
no_docs_found: 沒有找到文檔
|
7
|
+
no_docs_found_descr: 沒有找到文檔。
|
8
|
+
follow_instructions_html: 點擊 %{href} 查看描述。
|
9
|
+
follow_instructions_href: 高級指導
|
10
|
+
oops: Oops!!
|
11
|
+
resource_not_found_html: 沒有找到資源 %{res} 。
|
12
|
+
method_not_found_html: 沒有找到資源 %{res} 的方法 %{method} 。
|
13
|
+
goto_homepage_html: 試圖訪問 %{href}
|
14
|
+
goto_homepage_href: "%{app_name} API 文檔主頁"
|
15
|
+
required: 必填
|
16
|
+
optional: 選填
|
17
|
+
nil_allowed: 允許空值
|
18
|
+
param_name: 參數名字
|
19
|
+
params: 參數
|
20
|
+
examples: 示例
|
21
|
+
metadata: 元數據
|
22
|
+
errors: 錯誤
|
23
|
+
supported_formats: 支持格式
|
24
|
+
enable_javascript_html: 瀏覽 %{comments_href}前請允許執行 JavaScript 。
|
25
|
+
comments_powered_by_disqus: 評論技術支持 %{disqus}
|
26
|
+
api_documentation: API 文檔
|
27
|
+
headers: 頭部
|
28
|
+
header_name: 頭部名字
|
Binary file
|
Binary file
|
@@ -33,7 +33,8 @@ module Apipie
|
|
33
33
|
:see => [],
|
34
34
|
:formats => nil,
|
35
35
|
:api_versions => [],
|
36
|
-
:meta => nil
|
36
|
+
:meta => nil,
|
37
|
+
:show => true
|
37
38
|
}
|
38
39
|
end
|
39
40
|
end
|
@@ -111,6 +112,13 @@ module Apipie
|
|
111
112
|
_apipie_dsl_data[:examples] << example.strip_heredoc
|
112
113
|
end
|
113
114
|
|
115
|
+
# Determine if the method should be included
|
116
|
+
# in the documentation
|
117
|
+
def show(show)
|
118
|
+
return unless Apipie.active_dsl?
|
119
|
+
_apipie_dsl_data[:show] = show
|
120
|
+
end
|
121
|
+
|
114
122
|
# Describe whole resource
|
115
123
|
#
|
116
124
|
# Example:
|
@@ -17,7 +17,7 @@ module Apipie
|
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
|
-
attr_reader :full_description, :method, :resource, :apis, :examples, :see, :formats, :metadata, :headers
|
20
|
+
attr_reader :full_description, :method, :resource, :apis, :examples, :see, :formats, :metadata, :headers, :show
|
21
21
|
|
22
22
|
def initialize(method, resource, dsl_data)
|
23
23
|
@method = method.to_s
|
@@ -49,6 +49,12 @@ module Apipie
|
|
49
49
|
end
|
50
50
|
@params_ordered = ParamDescription.unify(@params_ordered)
|
51
51
|
@headers = dsl_data[:headers]
|
52
|
+
|
53
|
+
@show = if dsl_data.has_key? :show
|
54
|
+
dsl_data[:show]
|
55
|
+
else
|
56
|
+
true
|
57
|
+
end
|
52
58
|
end
|
53
59
|
|
54
60
|
def id
|
@@ -144,7 +150,8 @@ module Apipie
|
|
144
150
|
:examples => @examples,
|
145
151
|
:metadata => @metadata,
|
146
152
|
:see => see.map(&:to_json),
|
147
|
-
:headers => headers
|
153
|
+
:headers => headers,
|
154
|
+
:show => @show
|
148
155
|
}
|
149
156
|
end
|
150
157
|
|
@@ -47,11 +47,7 @@ module Apipie
|
|
47
47
|
@parent = @options[:parent]
|
48
48
|
@metadata = @options[:meta]
|
49
49
|
|
50
|
-
@required =
|
51
|
-
@options[:required]
|
52
|
-
else
|
53
|
-
Apipie.configuration.required_by_default?
|
54
|
-
end
|
50
|
+
@required = is_required?
|
55
51
|
|
56
52
|
@show = if @options.has_key? :show
|
57
53
|
@options[:show]
|
@@ -210,6 +206,18 @@ module Apipie
|
|
210
206
|
concern_subst(Apipie.markup_to_html(text || ''))
|
211
207
|
end
|
212
208
|
|
209
|
+
def is_required?
|
210
|
+
if @options.has_key?(:required)
|
211
|
+
if (@options[:required] == true) || (@options[:required] == false)
|
212
|
+
@options[:required]
|
213
|
+
else
|
214
|
+
Array(@options[:required]).include?(@method_description.method.to_sym)
|
215
|
+
end
|
216
|
+
else
|
217
|
+
Apipie.configuration.required_by_default?
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
213
221
|
end
|
214
222
|
|
215
223
|
end
|