apipie-rails 0.5.20 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +12 -21
  3. data/.github/workflows/rubocop-challenger.yml +28 -0
  4. data/.github/workflows/rubocop.yml +18 -0
  5. data/.gitignore +1 -0
  6. data/.rubocop.yml +128 -0
  7. data/.rubocop_todo.yml +2062 -0
  8. data/.vscode/settings.json +3 -0
  9. data/CHANGELOG.md +144 -0
  10. data/Gemfile +20 -0
  11. data/README.rst +106 -15
  12. data/Rakefile +0 -5
  13. data/apipie-rails.gemspec +18 -9
  14. data/app/controllers/apipie/apipies_controller.rb +14 -29
  15. data/app/helpers/apipie_helper.rb +1 -1
  16. data/app/public/apipie/javascripts/bundled/bootstrap-collapse.js +70 -41
  17. data/app/public/apipie/javascripts/bundled/bootstrap.js +1033 -479
  18. data/app/public/apipie/javascripts/bundled/jquery.js +5 -5
  19. data/app/public/apipie/stylesheets/bundled/bootstrap-responsive.min.css +9 -12
  20. data/app/public/apipie/stylesheets/bundled/bootstrap.min.css +9 -689
  21. data/app/views/apipie/apipies/_deprecation.html.erb +16 -0
  22. data/app/views/apipie/apipies/_params.html.erb +7 -1
  23. data/config/locales/en.yml +8 -0
  24. data/config/locales/ko.yml +31 -0
  25. data/gemfiles/Gemfile.tools +9 -0
  26. data/lib/apipie/apipie_module.rb +7 -7
  27. data/lib/apipie/application.rb +132 -97
  28. data/lib/apipie/configuration.rb +43 -33
  29. data/lib/apipie/dsl_definition.rb +39 -27
  30. data/lib/apipie/error_description.rb +3 -3
  31. data/lib/apipie/errors.rb +16 -16
  32. data/lib/apipie/extractor/collector.rb +4 -5
  33. data/lib/apipie/extractor/recorder.rb +33 -6
  34. data/lib/apipie/extractor/writer.rb +14 -14
  35. data/lib/apipie/extractor.rb +6 -9
  36. data/lib/apipie/generator/config.rb +12 -0
  37. data/lib/apipie/generator/generator.rb +2 -0
  38. data/lib/apipie/generator/swagger/computed_interface_id.rb +23 -0
  39. data/lib/apipie/generator/swagger/config.rb +80 -0
  40. data/lib/apipie/generator/swagger/context.rb +38 -0
  41. data/lib/apipie/generator/swagger/method_description/api_decorator.rb +20 -0
  42. data/lib/apipie/generator/swagger/method_description/api_schema_service.rb +89 -0
  43. data/lib/apipie/generator/swagger/method_description/decorator.rb +22 -0
  44. data/lib/apipie/generator/swagger/method_description/parameters_service.rb +139 -0
  45. data/lib/apipie/generator/swagger/method_description/response_schema_service.rb +46 -0
  46. data/lib/apipie/generator/swagger/method_description/response_service.rb +58 -0
  47. data/lib/apipie/generator/swagger/method_description.rb +2 -0
  48. data/lib/apipie/generator/swagger/operation_id.rb +51 -0
  49. data/lib/apipie/generator/swagger/param_description/builder.rb +105 -0
  50. data/lib/apipie/generator/swagger/param_description/composite.rb +119 -0
  51. data/lib/apipie/generator/swagger/param_description/description.rb +15 -0
  52. data/lib/apipie/generator/swagger/param_description/in.rb +37 -0
  53. data/lib/apipie/generator/swagger/param_description/name.rb +18 -0
  54. data/lib/apipie/generator/swagger/param_description/path_params_composite.rb +61 -0
  55. data/lib/apipie/generator/swagger/param_description/referenced_composite.rb +36 -0
  56. data/lib/apipie/generator/swagger/param_description/type.rb +115 -0
  57. data/lib/apipie/generator/swagger/param_description.rb +18 -0
  58. data/lib/apipie/generator/swagger/path_decorator.rb +36 -0
  59. data/lib/apipie/generator/swagger/referenced_definitions.rb +17 -0
  60. data/lib/apipie/generator/swagger/resource_description_collection.rb +30 -0
  61. data/lib/apipie/generator/swagger/resource_description_composite.rb +56 -0
  62. data/lib/apipie/generator/swagger/schema.rb +63 -0
  63. data/lib/apipie/generator/swagger/swagger.rb +2 -0
  64. data/lib/apipie/generator/swagger/type.rb +16 -0
  65. data/lib/apipie/generator/swagger/type_extractor.rb +51 -0
  66. data/lib/apipie/generator/swagger/warning.rb +74 -0
  67. data/lib/apipie/generator/swagger/warning_writer.rb +54 -0
  68. data/lib/apipie/helpers.rb +3 -3
  69. data/lib/apipie/markup.rb +9 -8
  70. data/lib/apipie/method_description/api.rb +12 -0
  71. data/lib/apipie/method_description/apis_service.rb +82 -0
  72. data/lib/apipie/method_description.rb +12 -56
  73. data/lib/apipie/param_description/deprecation.rb +24 -0
  74. data/lib/apipie/param_description.rb +57 -24
  75. data/lib/apipie/resource_description.rb +42 -14
  76. data/lib/apipie/response_description.rb +3 -3
  77. data/lib/apipie/response_description_adapter.rb +10 -8
  78. data/lib/apipie/routing.rb +1 -1
  79. data/lib/apipie/rspec/response_validation_helper.rb +3 -3
  80. data/lib/apipie/static_dispatcher.rb +3 -1
  81. data/lib/apipie/swagger_generator.rb +28 -691
  82. data/lib/apipie/validator.rb +40 -10
  83. data/lib/apipie/version.rb +1 -1
  84. data/lib/apipie-rails.rb +36 -5
  85. data/lib/generators/apipie/install/install_generator.rb +1 -1
  86. data/lib/generators/apipie/views_generator.rb +1 -1
  87. data/lib/tasks/apipie.rake +35 -30
  88. data/spec/controllers/api/v2/architectures_controller_spec.rb +10 -3
  89. data/spec/controllers/api/v2/empty_middle_controller_spec.rb +23 -0
  90. data/spec/controllers/api/v2/nested/resources_controller_spec.rb +18 -2
  91. data/spec/controllers/api/v2/sub/footguns_controller_spec.rb +19 -0
  92. data/spec/controllers/included_param_group_controller_spec.rb +13 -0
  93. data/spec/{lib/swagger/response_validation_spec.rb → controllers/pets_controller_spec.rb} +26 -32
  94. data/spec/controllers/users_controller_spec.rb +47 -6
  95. data/spec/dummy/Rakefile +1 -1
  96. data/spec/dummy/app/controllers/api/v2/architectures_controller.rb +2 -1
  97. data/spec/dummy/app/controllers/api/v2/base_controller.rb +6 -0
  98. data/spec/dummy/app/controllers/api/v2/empty_middle_controller.rb +14 -0
  99. data/spec/dummy/app/controllers/api/v2/nested/resources_controller.rb +2 -2
  100. data/spec/dummy/app/controllers/api/v2/sub/footguns_controller.rb +30 -0
  101. data/spec/dummy/app/controllers/concerns_controller.rb +1 -1
  102. data/spec/dummy/app/controllers/{concerns/extending_concern.rb → extending_concern.rb} +0 -2
  103. data/spec/dummy/app/controllers/included_param_group_controller.rb +19 -0
  104. data/spec/dummy/app/controllers/overridden_concerns_controller.rb +2 -2
  105. data/spec/dummy/app/controllers/pets_controller.rb +4 -4
  106. data/spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb +2 -2
  107. data/spec/dummy/app/controllers/{concerns/sample_controller.rb → sample_controller.rb} +0 -2
  108. data/spec/dummy/app/controllers/twitter_example_controller.rb +2 -2
  109. data/spec/dummy/app/controllers/users_controller.rb +17 -5
  110. data/spec/dummy/app/helpers/random_param_group.rb +8 -0
  111. data/spec/dummy/components/test_engine/test_engine.gemspec +1 -1
  112. data/spec/dummy/config/application.rb +2 -5
  113. data/spec/dummy/config/boot.rb +2 -2
  114. data/spec/dummy/config/environment.rb +1 -1
  115. data/spec/dummy/config/environments/development.rb +0 -3
  116. data/spec/dummy/config/environments/production.rb +0 -3
  117. data/spec/dummy/config/environments/test.rb +0 -5
  118. data/spec/dummy/config/initializers/apipie.rb +2 -2
  119. data/spec/dummy/config/routes.rb +8 -0
  120. data/spec/dummy/config.ru +1 -1
  121. data/spec/dummy/script/rails +2 -2
  122. data/spec/{controllers → lib/apipie}/apipies_controller_spec.rb +95 -23
  123. data/spec/lib/apipie/application_spec.rb +62 -0
  124. data/spec/lib/apipie/configuration_spec.rb +38 -0
  125. data/spec/lib/apipie/extractor/collector_spec.rb +57 -0
  126. data/spec/lib/apipie/extractor/recorder_spec.rb +77 -0
  127. data/spec/lib/{extractor → apipie/extractor}/writer_spec.rb +8 -6
  128. data/spec/lib/{file_handler_spec.rb → apipie/file_handler_spec.rb} +7 -0
  129. data/spec/lib/apipie/generator/swagger/config_spec.rb +19 -0
  130. data/spec/lib/apipie/generator/swagger/context_spec.rb +56 -0
  131. data/spec/lib/apipie/generator/swagger/method_description/api_schema_service_spec.rb +119 -0
  132. data/spec/lib/apipie/generator/swagger/method_description/response_schema_service_spec.rb +105 -0
  133. data/spec/lib/apipie/generator/swagger/operation_id_spec.rb +63 -0
  134. data/spec/lib/apipie/generator/swagger/param_description/builder_spec.rb +203 -0
  135. data/spec/lib/apipie/generator/swagger/param_description/composite_spec.rb +95 -0
  136. data/spec/lib/apipie/generator/swagger/param_description/description_spec.rb +79 -0
  137. data/spec/lib/apipie/generator/swagger/param_description/in_spec.rb +86 -0
  138. data/spec/lib/apipie/generator/swagger/param_description/name_spec.rb +81 -0
  139. data/spec/lib/apipie/generator/swagger/param_description/type_spec.rb +178 -0
  140. data/spec/lib/apipie/generator/swagger/param_description_spec.rb +28 -0
  141. data/spec/lib/apipie/generator/swagger/path_decorator_spec.rb +57 -0
  142. data/spec/lib/apipie/generator/swagger/referenced_definitions_spec.rb +35 -0
  143. data/spec/lib/apipie/generator/swagger/resource_description_composite_spec.rb +37 -0
  144. data/spec/lib/apipie/generator/swagger/resource_descriptions_collection_spec.rb +57 -0
  145. data/spec/lib/apipie/generator/swagger/schema_spec.rb +89 -0
  146. data/spec/lib/apipie/generator/swagger/type_extractor_spec.rb +38 -0
  147. data/spec/lib/apipie/generator/swagger/warning_spec.rb +51 -0
  148. data/spec/lib/apipie/generator/swagger/warning_writer_spec.rb +71 -0
  149. data/spec/lib/apipie/method_description/apis_service_spec.rb +60 -0
  150. data/spec/lib/apipie/method_description_spec.rb +133 -0
  151. data/spec/lib/apipie/no_documented_method_spec.rb +17 -0
  152. data/spec/lib/apipie/param_description/deprecation_spec.rb +31 -0
  153. data/spec/lib/{param_description_spec.rb → apipie/param_description_spec.rb} +332 -6
  154. data/spec/lib/{param_group_spec.rb → apipie/param_group_spec.rb} +6 -5
  155. data/spec/lib/apipie/resource_description_spec.rb +91 -0
  156. data/spec/lib/apipie/response_does_not_match_swagger_schema_spec.rb +35 -0
  157. data/spec/lib/apipie/swagger_generator_spec.rb +94 -0
  158. data/spec/lib/{validator_spec.rb → apipie/validator_spec.rb} +48 -12
  159. data/spec/lib/rake_spec.rb +3 -5
  160. data/spec/lib/swagger/openapi_2_0_schema.json +8 -1
  161. data/spec/lib/swagger/rake_swagger_spec.rb +24 -9
  162. data/spec/lib/swagger/swagger_dsl_spec.rb +18 -12
  163. data/spec/lib/validators/array_validator_spec.rb +1 -1
  164. data/spec/spec_helper.rb +10 -32
  165. data/spec/support/custom_bool_validator.rb +17 -0
  166. data/spec/{controllers → test_engine}/memes_controller_spec.rb +1 -1
  167. metadata +169 -122
  168. data/Gemfile +0 -1
  169. data/gemfiles/Gemfile.rails42 +0 -14
  170. data/gemfiles/Gemfile.rails42.lock +0 -160
  171. data/gemfiles/Gemfile.rails52 +0 -9
  172. data/gemfiles/Gemfile.rails60 +0 -10
  173. data/gemfiles/Gemfile.rails61 +0 -10
  174. data/spec/lib/application_spec.rb +0 -49
  175. data/spec/lib/method_description_spec.rb +0 -98
  176. data/spec/lib/resource_description_spec.rb +0 -48
  177. data/spec/support/rails-42-ruby-26.rb +0 -15
  178. /data/spec/lib/{extractor → apipie/extractor/recorder}/middleware_spec.rb +0 -0
  179. /data/spec/lib/{extractor → apipie}/extractor_spec.rb +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ "rubyLsp.bundleGemfile": "gemfiles/Gemfile.tools"
3
+ }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,149 @@
1
1
  Changelog
2
2
  ===========
3
+
4
+ ## [v1.2.3](https://github.com/Apipie/apipie-rails/tree/v1.2.3) (2023-10-11)
5
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v1.2.2...v1.2.3)
6
+ * Fix param: Consider default_value: nil as valid config ([#894](https://github.com/Apipie/apipie-rails/pull/894)) (davidwessman)
7
+
8
+ ## [v1.2.2](https://github.com/Apipie/apipie-rails/tree/v1.2.2) (2023-07-18)
9
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v1.2.1...v1.2.2)
10
+ * Fixed Swagger warnings for properties ([#892](https://github.com/Apipie/apipie-rails/pull/892)) (shev-vadim-net)
11
+ * Improved support for multipart/form-data example recording ([#891](https://github.com/Apipie/apipie-rails/pull/891)) (Butiri Cristian & hossenlopp)
12
+ * rubocop (1.54.2) fixes required with latest version ([#893](https://github.com/Apipie/apipie-rails/pull/893)) (Mathieu Jobin)
13
+
14
+ ## [v1.2.1](https://github.com/Apipie/apipie-rails/tree/v1.2.1) (2023-06-09)
15
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v1.2.0...v1.2.1)
16
+ * rspec: Fixes deprecated matcher ([#882](https://github.com/Apipie/apipie-rails/pull/882)) (David Wessman)
17
+ * Fix streaming bug ([#677](https://github.com/Apipie/apipie-rails/pull/677)) (Hunter Braun)
18
+ * Update README URLs based on HTTP redirects ([#448](https://github.com/Apipie/apipie-rails/pull/448)) (ReadmeCritic)
19
+ * Swagger: Adds option to skip default tags ([#881](https://github.com/Apipie/apipie-rails/pull/881)) (David Wessman)
20
+ * Parameter validation: Raises error for all missing ([#886](https://github.com/Apipie/apipie-rails/pull/886)) (David Wessman)
21
+
22
+ ## [v1.2.0](https://github.com/Apipie/apipie-rails/tree/v1.2.0) (2023-06-03)
23
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v1.1.0...v1.2.0)
24
+ * Allow resource_name to be inherited ([#872](https://github.com/Apipie/apipie-rails/pull/872)) (Eric Hankins)
25
+ * Fix cache rendering with namespaced resources ([#874](https://github.com/Apipie/apipie-rails/pull/874)) (Eric Hankins)
26
+ * Fix deprecated content_type on Rails >= 6 ([#879](https://github.com/Apipie/apipie-rails/pull/879)) (Eric Hankins)
27
+ * Fix typo in Collector ([#877](https://github.com/Apipie/apipie-rails/pull/877)) (Eric Hankins)
28
+ * Fix error climbing controller hierarchy ([#875](https://github.com/Apipie/apipie-rails/pull/875)) (Eric Hankins)
29
+ * Add Gemfile.tools for IDE usage ([#876](https://github.com/Apipie/apipie-rails/pull/876)) (Eric Hankins)
30
+ * Fix rubocop ([#883](https://github.com/Apipie/apipie-rails/pull/883)) (Mathieu Jobin)
31
+ * Performance/InefficientHashSearch-20230602233137 ([#884](https://github.com/Apipie/apipie-rails/pull/884)) (RuboCop challenger)
32
+ * Redo Github action script to not need individual gemfiles ([#885](https://github.com/Apipie/apipie-rails/pull/885)) (Mathieu Jobin)
33
+
34
+ ## [v1.1.0](https://github.com/Apipie/apipie-rails/tree/v1.1.0) (2023-05-16)
35
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v1.0.0...v1.1.0)
36
+ * Improve performance of route detection [#870](https://github.com/Apipie/apipie-rails/pull/870) (Eric Hankins)
37
+ * Fix startup crash due to typo [#869](https://github.com/Apipie/apipie-rails/pull/869) (Eric Hankins)
38
+ * Skip parse body for pdf responses [#871](https://github.com/Apipie/apipie-rails/pull/871) (Juan Gomez)
39
+ * add missing 'returns' translation [#868](https://github.com/Apipie/apipie-rails/pull/868) (Anthony Robertson)
40
+
41
+ ## [v1.0.0](https://github.com/Apipie/apipie-rails/tree/v1.0.0) (2023-04-26)
42
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.9.4...v1.0.0)
43
+ * Refactor Swagger generator [#816](https://github.com/Apipie/apipie-rails/pull/816) (Panos Dalitsouris)
44
+ * Take into account validator options for `required` ParamDescription [#863](https://github.com/Apipie/apipie-rails/pull/863) (Panos Dalitsouris)
45
+ * Replace `get_resource_name` with `get_resource_id` [#864](https://github.com/Apipie/apipie-rails/pull/864) (Panos Dalitsouris)
46
+ * Namespace swagger configuration [#862](https://github.com/Apipie/apipie-rails/pull/862) (Panos Dalitsouris)
47
+ * Allow boolean array `[true, false]` to be a valid argument for BooleanValidator [#848](https://github.com/Apipie/apipie-rails/pull/848) (Panos Dalitsouris)
48
+ * Fix swagger warnings [#865](https://github.com/Apipie/apipie-rails/pull/865) (Panos Dalitsouris)
49
+ * Update README - Adds the new Integer option you added recently to the documentation here. [#866](https://github.com/Apipie/apipie-rails/pull/866) (Jeremy Lupoli)
50
+ * [Rubocop] More Rubocop Auto corrections [#859](https://github.com/Apipie/apipie-rails/pull/859)
51
+
52
+ ## [v0.9.4](https://github.com/Apipie/apipie-rails/tree/v0.9.4) (2023-04-11)
53
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.9.3...v0.9.4)
54
+ * [Fix] Separate nested resource name [#855](https://github.com/Apipie/apipie-rails/pull/855), [#455](https://github.com/Apipie/apipie-rails/issues/455) (Panos Dalitsouris)
55
+ * [Rubocop] Disable a few Rubocop Rules, run Rubocop with ruby 3.2 [#851](https://github.com/Apipie/apipie-rails/pull/851), [#853](https://github.com/Apipie/apipie-rails/pull/853), [#840](https://github.com/Apipie/apipie-rails/pull/840), [#841](https://github.com/Apipie/apipie-rails/pull/841) (Panos Dalitsouris)
56
+ * [Rubocop] More Rubocop Auto corrections [#858](https://github.com/Apipie/apipie-rails/pull/858), [#849](https://github.com/Apipie/apipie-rails/pull/849), [#850](https://github.com/Apipie/apipie-rails/pull/850), [#844](https://github.com/Apipie/apipie-rails/pull/844), [#846](https://github.com/Apipie/apipie-rails/pull/846), [#834](https://github.com/Apipie/apipie-rails/pull/834), [#847](https://github.com/Apipie/apipie-rails/pull/847) (Rubocop Challenger)
57
+
58
+ ## [v0.9.3](https://github.com/Apipie/apipie-rails/tree/v0.9.3) (2023-03-08)
59
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.9.2...v0.9.3)
60
+ * [Feature] Allow Apipie::ParamDescription to be marked as deprecated [#819](https://github.com/Apipie/apipie-rails/pull/819), [#811](https://github.com/Apipie/apipie-rails/pull/811) (Panos Dalitsouris)
61
+ * [Fix] Make html markup thread safe ([#822](https://github.com/Apipie/apipie-rails/issues/822)) (Adam Růžička)
62
+ * [Feature] Allow action matcher strategy to be configured [#821](https://github.com/Apipie/apipie-rails/pull/821) (Panos Dalitsouris)
63
+ * [CI] Run Rubocop when opening PR [#826](https://github.com/Apipie/apipie-rails/pull/826) (Panos Dalitsouris)
64
+ * [CI] Green rubocop - Fix after rubocop challenger upgrade [#829](https://github.com/Apipie/apipie-rails/pull/829) (Mathieu Jobin)
65
+ * [Rubocop] More Rubocop Auto corrections [#818](https://github.com/Apipie/apipie-rails/pull/818), [#825](https://github.com/Apipie/apipie-rails/pull/825), [#827](https://github.com/Apipie/apipie-rails/pull/827), [#837](https://github.com/Apipie/apipie-rails/pull/837), [#839](https://github.com/Apipie/apipie-rails/pull/839) (Rubocop Challenger)
66
+
67
+ ## [v0.9.2](https://github.com/Apipie/apipie-rails/tree/v0.9.2) (2023-02-07)
68
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.9.1...v0.9.2)
69
+ * [Rubocop] More Rubocop Auto corrections [#795](https://github.com/Apipie/apipie-rails/pull/795), [#781](https://github.com/Apipie/apipie-rails/pull/781), [#791](https://github.com/Apipie/apipie-rails/pull/791), [#788](https://github.com/Apipie/apipie-rails/pull/788) (Rubocop Challenger)
70
+ * [Fix] Can't include translation in full description ([#446](https://github.com/Apipie/apipie-rails/issues/446)) [#808](https://github.com/Apipie/apipie-rails/pull/808) (Peter Nagy)
71
+ * [Refactor] Move swagger param description creation [#810](https://github.com/Apipie/apipie-rails/pull/810) (Panos Dalitsouris)
72
+ * [Rubocop] Redo rubocop TODOs, set HashSyntax config to most used style [#814](https://github.com/Apipie/apipie-rails/pull/814) (Mathieu Jobin)
73
+ * [Fix] Swagger missing i18n [#815](https://github.com/Apipie/apipie-rails/pull/815) (@jirubio)
74
+
75
+ ## [v0.9.1](https://github.com/Apipie/apipie-rails/tree/v0.9.1) (2023-01-16)
76
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.9.0...v0.9.1)
77
+ * [Refactor] Create test cache files under a not version controlled directory [#809](https://github.com/Apipie/apipie-rails/pull/809) (Panos Dalitsouris)
78
+ * [Ruby] Support for Ruby 3.2 [#807](https://github.com/Apipie/apipie-rails/pull/807) (Mathieu Jobin)
79
+ * [Fix] Reverted conditional assignment operators that caused #559 [#806](https://github.com/Apipie/apipie-rails/pull/806) (Nick L. Deltik)
80
+ * [Rubocop] Autocorrect Style/SymbolProc [#793](https://github.com/Apipie/apipie-rails/pull/793) (Rubocop Challenger)
81
+
82
+ ## [v0.9.0](https://github.com/Apipie/apipie-rails/tree/v0.9.0) (2023-01-03)
83
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.8.2...v0.9.0)
84
+ * [Refactor] Move Swagger types and warnings under `/generator` namespace [#803](https://github.com/Apipie/apipie-rails/pull/803) (Panos Dalitsouris)
85
+ * [Refactor] Creates `Apipie::MethodDescription::ApisService` [#805](https://github.com/Apipie/apipie-rails/pull/805) (Panos Dalitsouris)
86
+ * [Refactor] Change output folder to `spec/dummy/tmp/` [#804](https://github.com/Apipie/apipie-rails/pull/804) (Panos Dalitsouris)
87
+ * Fix tiny typo in docs [#798](https://github.com/Apipie/apipie-rails/pull/798) (Erik-B. Ernst)
88
+ * Fix Generated docs.json output [#787](https://github.com/Apipie/apipie-rails/pull/787) (Jeremy Liberman)
89
+ * Rubocop Fixes [#775](https://github.com/Apipie/apipie-rails/pull/775), [#778](https://github.com/Apipie/apipie-rails/pull/778), [#780](https://github.com/Apipie/apipie-rails/pull/780), [#790](https://github.com/Apipie/apipie-rails/pull/790), [#783](https://github.com/Apipie/apipie-rails/pull/783), [#785](https://github.com/Apipie/apipie-rails/pull/785) (RuboCop)
90
+ * Remove/clean up dev dependencies and unused rake tasks [#777](https://github.com/Apipie/apipie-rails/pull/777) (Mathieu Jobin)
91
+ - remove unused rake task
92
+ * Setup Rubocop Challenger [#776](https://github.com/Apipie/apipie-rails/pull/776) (Mathieu Jobin)
93
+
94
+ ## [v0.8.2](https://github.com/Apipie/apipie-rails/tree/v0.8.2) (2022-09-03)
95
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.8.1...v0.8.2)
96
+ * Allow custom validators to opt out of allow_blank behavior [#762](https://github.com/Apipie/apipie-rails/pull/762). (Stephen Hanson)
97
+ * Enforce test coverage, set current 89% as minimum [#764](https://github.com/Apipie/apipie-rails/pull/764). (Mathieu Jobin)
98
+ * Add contributing instructions to readme [#763](https://github.com/Apipie/apipie-rails/pull/763). (Stephen Hanson)
99
+ * Fix readme formatting [#765](https://github.com/Apipie/apipie-rails/pull/765). (Stephen Hanson)
100
+ * Adds expected_type to IntegerValidator example [#769](https://github.com/Apipie/apipie-rails/pull/769). (Jeremy Liberman)
101
+ * Update readme with error handling example [#768](https://github.com/Apipie/apipie-rails/pull/768). (Jesse Eisenberg)
102
+ * Fix scope incorrectly set to nil when a param_group is used inside an array_of_hash and the param_group is in a different module / controller. [#693](https://github.com/Apipie/apipie-rails/pull/693) [#774](https://github.com/Apipie/apipie-rails/pull/774). (Omkar Joshi / Oliver Iyer)
103
+
104
+ ## [v0.8.1](https://github.com/Apipie/apipie-rails/tree/v0.8.1) (2022-05-26)
105
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.8.0...v0.8.1)
106
+ * Remove warning that came back as of [#752](https://github.com/Apipie/apipie-rails/pull/752). [#761](https://github.com/Apipie/apipie-rails/pull/761) (Jorge Santos / Mathieu Jobin)
107
+
108
+ ## [v0.8.0](https://github.com/Apipie/apipie-rails/tree/v0.8.0) (2022-05-24)
109
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.7.2...v0.8.0)
110
+ * Add support for scheme definition in Swagger docs. [#710](https://github.com/Apipie/apipie-rails/pull/710) (Dan Leyden)
111
+ * Add support for Rails 7 [#760](https://github.com/Apipie/apipie-rails/pull/760) (Mathieu Jobin)
112
+ * Clean up code base, removing all trace of unsupported Rails 4.x [#752](https://github.com/Apipie/apipie-rails/pull/752) (Mathieu Jobin)
113
+ * fix: Controller resource set before version [#744](https://github.com/Apipie/apipie-rails/pull/744) (LuukvH)
114
+ * fix: enable swagger generator to add referenced schema for an array of hashes param [#689](https://github.com/Apipie/apipie-rails/pull/689) (Francis San Juan)
115
+
116
+ ## [v0.7.2](https://github.com/Apipie/apipie-rails/tree/v0.7.2) (2022-04-19)
117
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.7.1...v0.7.2)
118
+ * Added Korean locale. [#480](https://github.com/Apipie/apipie-rails/pull/480) (Jaehyun Shin ) [#757](https://github.com/Apipie/apipie-rails/pull/757) (Jorge Santos)
119
+ * `Security` Upgraded Bootstrap from 2.0.2 to 2.3.2, JQuery from 1.11.3 to 1.12.4 [#708](https://github.com/Apipie/apipie-rails/pull/708) (Nicolas Waissbluth)
120
+ * Fix ruby2 keyword argument warning [#756](https://github.com/Apipie/apipie-rails/pull/756) (Jorge Santos)
121
+
122
+ ## [v0.7.1](https://github.com/Apipie/apipie-rails/tree/v0.7.1) (2022-04-06)
123
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.7.0...v0.7.1)
124
+ * Skip extra parameters while validating the keys. [#690](https://github.com/Apipie/apipie-rails/pull/690) (Omkar Joshi)
125
+ * Support defining security mechanisms for Swagger [#711](https://github.com/Apipie/apipie-rails/pull/711) (Dan Leyden)
126
+ * Update boolean handling of false [#749](https://github.com/Apipie/apipie-rails/pull/749) (Colin Bruce)
127
+
128
+ Note: Up until and including v0.6.x, apipie-rails was silently ignoring allow_blank == false on String validation.
129
+ when allow_blank is not specified, it default to false. to allow blank strings, you must specify it as a parameter.
130
+
131
+ Alternatively, if you want to revert to the previous behavior, you can set this configuration option:
132
+ `Apipie.configuration.ignore_allow_blank_false = true`.
133
+
134
+ ## [v0.7.0](https://github.com/Apipie/apipie-rails/tree/v0.7.0) (2022-03-30)
135
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.6.0...v0.7.0)
136
+ * ArgumentError (invalid byte sequence in UTF-8) [#746](https://github.com/Apipie/apipie-rails/pull/746) (David Milanese)
137
+ * Fix allow_blank does not work [#733](https://github.com/Apipie/apipie-rails/pull/733) (CHEN Song)
138
+ * Fix schema generation for param descriptions using the array validator in option [#732](https://github.com/Apipie/apipie-rails/pull/732) (Frank Hock)
139
+ * Remove support for Rails 4 and Ruby <= 2.5 [#747](https://github.com/Apipie/apipie-rails/pull/747) (Mathieu Jobin)
140
+
141
+ ## [v0.6.0](https://github.com/Apipie/apipie-rails/tree/v0.6.0) (2022-03-29)
142
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.5.20...v0.6.0)
143
+ * Ruby 3.0 fixes [#716](https://github.com/Apipie/apipie-rails/pull/716) (hank-spokeo)
144
+ * only depends on actionpack and activesupport [#741](https://github.com/Apipie/apipie-rails/pull/741) (Mathieu Jobin)
145
+ * language fix, fallback to default locale [#726](https://github.com/Apipie/apipie-rails/pull/726) (Alex Coomans)
146
+
3
147
  ## [v0.5.20](https://github.com/Apipie/apipie-rails/tree/v0.5.20) (2022-03-16)
4
148
  [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.5.19...v0.5.20)
5
149
  * Update rel-eng (Oleh Fedorenko)
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec path: '.'
6
+
7
+ # use ENV vars, with default value as fallback for local setup
8
+ ruby(ENV['RUBY_VERSION'] || '3.2.2')
9
+ gem 'actionpack', "~> #{ENV['RAILS_VERSION'] || '7.0'}.0"
10
+ gem 'activesupport', "~> #{ENV['RAILS_VERSION'] || '7.0'}.0"
11
+
12
+ gem 'mime-types' # , '~> 3.0'
13
+ gem 'rails-controller-testing'
14
+ gem 'rspec-rails' # , '~> 5.0'
15
+
16
+ # net-smtp not included by default in Ruby 3.1
17
+ # Will be fixed by https://github.com/mikel/mail/pull/1439
18
+ gem 'net-smtp', require: false if Gem.ruby_version >= Gem::Version.new('3.1.0')
19
+
20
+ gem 'test_engine', path: './spec/dummy/components/test_engine', group: :test
data/README.rst CHANGED
@@ -2,8 +2,8 @@
2
2
  API Documentation Tool
3
3
  ========================
4
4
 
5
- .. image:: https://travis-ci.org/Apipie/apipie-rails.svg?branch=master
6
- :target: https://travis-ci.org/Apipie/apipie-rails
5
+ .. image:: https://github.com/Apipie/apipie-rails/actions/workflows/build.yml/badge.svg
6
+ :target: https://github.com/Apipie/apipie-rails/actions/workflows/build.yml
7
7
  .. image:: https://codeclimate.com/github/Apipie/apipie-rails.svg
8
8
  :target: https://codeclimate.com/github/Apipie/apipie-rails
9
9
  .. image:: https://badges.gitter.im/Apipie/apipie-rails.svg
@@ -56,7 +56,7 @@ Run your application and see the result at
56
56
  use ``http://localhost:3000/apipie.json``.
57
57
 
58
58
  For a more comprehensive getting started guide, see
59
- `this demo <https://github.com/iNecas/apipie-demo>`_, which includes
59
+ `this demo <https://github.com/Apipie/apipie-demo>`_, which includes
60
60
  features such as generating documentation from tests, recording examples etc.
61
61
 
62
62
  Screenshots
@@ -78,7 +78,7 @@ See `Contributors page <https://github.com/Apipie/apipie-rails/graphs/contribut
78
78
  License
79
79
  -------
80
80
 
81
- Apipie-rails is released under the `MIT License <http://opensource.org/licenses/MIT>`_
81
+ Apipie-rails is released under the `MIT License <https://opensource.org/licenses/MIT>`_
82
82
 
83
83
  ===============
84
84
  Documentation
@@ -108,6 +108,10 @@ resource_id
108
108
  name
109
109
  Human readable name of resource. By default ``class.name.humanize`` is used.
110
110
 
111
+ - Can be specified as a proc, which will receive the controller class as an argument.
112
+ - Can be a symbol, which will be sent to the controller class to get the name.
113
+ - Can be a string, which will be used as is.
114
+
111
115
  short (also short_description)
112
116
  Short description of the resource (it's shown on both the list of resources, and resource details)
113
117
 
@@ -150,7 +154,7 @@ Example:
150
154
  resource_description do
151
155
  short 'Site members'
152
156
  formats ['json']
153
- param :id, Fixnum, :desc => "User ID", :required => false
157
+ param :id, Integer, :desc => "User ID", :required => false
154
158
  param :resource_param, Hash, :desc => 'Param description for all methods' do
155
159
  param :ausername, String, :desc => "Username for login", :required => true
156
160
  param :apassword, String, :desc => "Password for login", :required => true
@@ -355,6 +359,22 @@ Example:
355
359
  #...
356
360
  end
357
361
 
362
+ deprecated
363
+ Indicates if the parameter is marked as deprecated.
364
+
365
+ Example
366
+ ~~~~~~~~
367
+
368
+ .. code:: ruby
369
+
370
+ param :pet_name, String, desc: "Name of pet", deprecated: true
371
+ param :pet_name, String, desc: "Name of pet", deprecated: 'Some deprecation info'
372
+ param :pet_name, String, desc: "Name of pet", deprecated: { in: "2.3", info: "Something", sunset: "3.0" }
373
+ def create
374
+ #...
375
+ end
376
+
377
+
358
378
  DRY with param_group
359
379
  --------------------
360
380
 
@@ -966,6 +986,9 @@ validate_presence
966
986
  validate_key
967
987
  Check the received params to ensure they are defined in the API. (false by default)
968
988
 
989
+ action_on_non_validated_keys
990
+ Either `:raise` or `:skip`. If `validate_key` fails, raise error or delete the non-validated key from the params and log the key (`:raise` by default)
991
+
969
992
  process_params
970
993
  Process and extract the parameter defined from the params of the request
971
994
  to the api_params variable
@@ -979,6 +1002,9 @@ reload_controllers
979
1002
  api_controllers_matcher
980
1003
  For reloading to work properly you need to specify where your API controllers are. Can be an array if multiple paths are needed
981
1004
 
1005
+ api_action_matcher
1006
+ Determines the strategy to identity the correct controller action. Needs to be a class that implements a `.call(controller)` method
1007
+
982
1008
  api_routes
983
1009
  Set if your application uses a custom API router, different from the Rails
984
1010
  default
@@ -1021,6 +1047,10 @@ authorize
1021
1047
  show_all_examples
1022
1048
  Set this to true to set show_in_doc=1 in all recorded examples
1023
1049
 
1050
+ ignore_allow_blank_false
1051
+ `allow_blank: false` was incorrectly ignored up until version 0.6.0, this bug was fixed in 0.7.0
1052
+ if you need the old behavior, set this to true
1053
+
1024
1054
  link_extension
1025
1055
  The extension to use for API pages ('.html' by default). Link extensions
1026
1056
  in static API docs cannot be changed from '.html'.
@@ -1056,6 +1086,7 @@ Example:
1056
1086
  config.markup = Apipie::Markup::Markdown.new
1057
1087
  config.reload_controllers = Rails.env.development?
1058
1088
  config.api_controllers_matcher = File.join(Rails.root, "app", "controllers", "**","*.rb")
1089
+ config.api_action_matcher = proc { |controller| controller.params[:action] }
1059
1090
  config.api_routes = Rails.application.routes
1060
1091
  config.app_info["1.0"] = "
1061
1092
  This is where you can inform user about your application and API
@@ -1149,6 +1180,21 @@ is raised and can be rescued and processed. It contains a description
1149
1180
  of the parameter value expectations. Validations can be turned off
1150
1181
  in the configuration file.
1151
1182
 
1183
+ Here is an example of how to rescue and process a +ParamMissing+ or
1184
+ +ParamInvalid+ error from within the ApplicationController.
1185
+
1186
+ .. code:: ruby
1187
+
1188
+ class ApplicationController < ActionController::Base
1189
+
1190
+ # ParamError is superclass of ParamMissing, ParamInvalid
1191
+ rescue_from Apipie::ParamError do |e|
1192
+ render text: e.message, status: :unprocessable_entity
1193
+ end
1194
+
1195
+ # ...
1196
+ end
1197
+
1152
1198
  Parameter validation normally happens after before_actions, just before
1153
1199
  your controller method is invoked. If you prefer to control when parameter
1154
1200
  validation occurs, set the configuration parameter ``validate`` to ``:explicitly``.
@@ -1163,7 +1209,7 @@ after the ``apipie_validations`` before_action.
1163
1209
 
1164
1210
  TypeValidator
1165
1211
  -------------
1166
- Check the parameter type. Only String, Hash and Array are supported
1212
+ Check the parameter type. Only String, Integer, Hash and Array are supported
1167
1213
  for the sake of simplicity. Read more to find out how to add
1168
1214
  your own validator.
1169
1215
 
@@ -1353,7 +1399,7 @@ So we create apipie_validators.rb initializer with this content:
1353
1399
  end
1354
1400
 
1355
1401
  def self.build(param_description, argument, options, block)
1356
- if argument == Integer || argument == Fixnum
1402
+ if argument == Integer
1357
1403
  self.new(param_description, argument)
1358
1404
  end
1359
1405
  end
@@ -1361,6 +1407,10 @@ So we create apipie_validators.rb initializer with this content:
1361
1407
  def description
1362
1408
  "Must be #{@type}."
1363
1409
  end
1410
+
1411
+ def expected_type
1412
+ 'numeric'
1413
+ end
1364
1414
  end
1365
1415
 
1366
1416
  Parameters of the build method:
@@ -1378,6 +1428,16 @@ options
1378
1428
  block
1379
1429
  Block converted into Proc, use it as you desire. In this example nil.
1380
1430
 
1431
+ If your validator includes valid values that respond true to `.blank?`, you
1432
+ should also define:
1433
+
1434
+ .. code:: ruby
1435
+
1436
+ def ignore_allow_blank?
1437
+ true
1438
+ end
1439
+
1440
+ so that the validation does not fail for valid values.
1381
1441
 
1382
1442
  ============
1383
1443
  Versioning
@@ -1608,7 +1668,7 @@ Swagger-Specific Configuration Parameters
1608
1668
 
1609
1669
  There are several configuration parameters that determine the structure of the generated swagger file:
1610
1670
 
1611
- ``config.swagger_content_type_input``
1671
+ ``config.generator.swagger.content_type_input``
1612
1672
  If the value is ``:form_data`` - the swagger file will indicate that the server consumes the content types
1613
1673
  ``application/x-www-form-urlencoded`` and ``multipart/form-data``. Non-path parameters will have the
1614
1674
  value ``"in": "formData"``. Note that parameters of type Hash that do not have any fields in them will *be ommitted*
@@ -1621,38 +1681,58 @@ There are several configuration parameters that determine the structure of the g
1621
1681
  You can specify the value of this configuration parameter as an additional input to the rake command (e.g.,
1622
1682
  ``rake apipie:static_swagger_json[2.0,form_data]``).
1623
1683
 
1624
- ``config.swagger_json_input_uses_refs``
1625
- This parameter is only relevant if ``swagger_content_type_input`` is ``:json``.
1684
+ ``config.generator.swagger.json_input_uses_refs``
1685
+ This parameter is only relevant if ``swagger.content_type_input`` is ``:json``.
1626
1686
 
1627
1687
  If ``true``: the schema of the ``"in": "body"`` parameter of each method is given its own entry in the ``definitions``
1628
1688
  section, and is referenced using ``$ref`` from the method definition.
1629
1689
 
1630
1690
  If ``false``: the body parameter definitions are inlined within the method definitions.
1631
1691
 
1632
- ``config.swagger_include_warning_tags``
1692
+ ``config.generator.swagger.include_warning_tags``
1633
1693
  If ``true``: in addition to tagging methods with the name of the resource they belong to, methods for which warnings
1634
1694
  have been issued will be tagged with.
1635
1695
 
1636
- ``config.swagger_suppress_warnings``
1696
+ ``config.generator.swagger.suppress_warnings``
1637
1697
  If ``false``: no warnings will be suppressed
1638
1698
 
1639
1699
  If ``true``: all warnings will be suppressed
1640
1700
 
1641
1701
  If an array of values (e.g., ``[100,102,107]``), only the warnings identified by the numbers in the array will be suppressed.
1642
1702
 
1643
- ``config.swagger_api_host``
1703
+ ``config.generator.swagger.api_host``
1644
1704
  The value to place in the swagger host field.
1645
1705
 
1646
1706
  Default is ``localhost:3000``
1647
1707
 
1648
1708
  If ``nil`` then then host field will not be included.
1649
1709
 
1650
- ``config.swagger_allow_additional_properties_in_response``
1710
+ ``config.generator.swagger.allow_additional_properties_in_response``
1651
1711
  If ``false`` (default): response descriptions in the generated swagger will include an ``additional-properties: false``
1652
1712
  field
1653
1713
 
1654
1714
  If ``true``: the ``additional-properties: false`` field will not be included in response object descriptions
1655
1715
 
1716
+ ``config.generator.swagger.schemes``
1717
+ An array of transport schemes that the API supports.
1718
+ This can include any combination of ``http``, ``https``, ``ws`` and ``wss``.
1719
+ By default to encourage good security practices, ``['https']`` is specified.
1720
+
1721
+
1722
+ ``config:swagger.security_definitions``
1723
+ If the API requires authentication, you can specify details of the authentication mechanisms supported as a (Hash) value here.
1724
+ See [https://swagger.io/docs/specification/2-0/authentication/] for details of what values can be specified
1725
+ By default, no security is defined.
1726
+
1727
+ ``config.generator.swagger.global_security``
1728
+ If the API requires authentication, you can specify which of the authentication mechanisms are supported by all API operations as an Array of hashes here.
1729
+ This should be used in conjunction with the mechanisms defined by ``swagger.security_definitions``.
1730
+ See [https://swagger.io/docs/specification/2-0/authentication/] for details of what values can be specified
1731
+ By default, no security is defined.
1732
+
1733
+ ``config.generator.swagger.skip_default_tags``
1734
+ By setting ``false`` (default): The resource name for e.g. ``/pets/{petId}`` will automatically be added as a tag ``pets``.
1735
+ By setting ``true``: The tags needs to be explicitly added to the resource using the DSL.
1656
1736
 
1657
1737
  Known limitations of the current implementation
1658
1738
  -------------------------------------------------
@@ -1663,6 +1743,7 @@ Known limitations of the current implementation
1663
1743
  * It is not possible to leverage all of the parameter type/format capabilities of swagger
1664
1744
  * Only OpenAPI 2.0 is supported
1665
1745
  * Responses are defined inline and not as a $ref
1746
+ * It is not possible to specify per-operation security requirements (only global)
1666
1747
 
1667
1748
  ====================================
1668
1749
  Dynamic Swagger generation
@@ -1847,12 +1928,22 @@ provided it uses Apipie as a backend.
1847
1928
 
1848
1929
  And if you write one on your own, don't hesitate to share it with us!
1849
1930
 
1931
+ ====================
1932
+ Contributing
1933
+ ====================
1934
+
1935
+ Then, you can install dependencies and run the test suite:
1936
+
1937
+ .. code:: shell
1938
+
1939
+ > bundle install
1940
+ > bundle exec rspec
1850
1941
 
1851
1942
  ====================
1852
1943
  Disqus Integration
1853
1944
  ====================
1854
1945
 
1855
- You can setup `Disqus <http://www.disqus.com>`_ discussion within
1946
+ You can setup `Disqus <https://disqus.com/>`_ discussion within
1856
1947
  your documentation. Just set the credentials in the Apipie
1857
1948
  configuration:
1858
1949
 
data/Rakefile CHANGED
@@ -6,8 +6,3 @@ RSpec::Core::RakeTask.new(:spec)
6
6
  desc 'Default: run specs.'
7
7
  task :default => :spec
8
8
 
9
- desc "Generate code coverage"
10
- RSpec::Core::RakeTask.new(:coverage) do |t|
11
- t.rcov = true
12
- t.rcov_opts = ['--exclude', 'spec']
13
- end
data/apipie-rails.gemspec CHANGED
@@ -1,5 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ $:.push File.expand_path('lib', __dir__)
3
4
  require "apipie/version"
4
5
 
5
6
  Gem::Specification.new do |s|
@@ -10,19 +11,27 @@ Gem::Specification.new do |s|
10
11
  s.homepage = "http://github.com/Apipie/apipie-rails"
11
12
  s.summary = %q{Rails REST API documentation tool}
12
13
  s.description = %q{Rails REST API documentation tool}
13
- s.required_ruby_version = '>= 2.0.0'
14
+ s.required_ruby_version = '>= 2.6.0'
14
15
 
15
16
  s.files = `git ls-files`.split("\n")
16
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
18
  s.require_paths = ["lib"]
18
19
 
19
- s.add_dependency "rails", ">= 4.1"
20
+ s.add_dependency "actionpack", ">= 5.0"
21
+ s.add_dependency "activesupport", ">= 5.0"
22
+
23
+ # Optional dependencies
24
+ s.add_development_dependency "maruku" # for Markdown support
25
+ s.add_development_dependency "RedCloth" # for Textile support
26
+
27
+ # Dev/tests only dependencies
28
+ s.add_development_dependency "json-schema", "~> 2.8"
20
29
  s.add_development_dependency "rspec-rails", "~> 3.0"
21
- s.add_development_dependency "sqlite3"
22
- s.add_development_dependency "minitest"
23
- s.add_development_dependency "maruku"
24
- s.add_development_dependency "RedCloth"
25
30
  s.add_development_dependency "rake"
26
- s.add_development_dependency "rdoc"
27
- s.add_development_dependency "json-schema", "~> 2.8"
31
+ s.add_development_dependency 'rubocop_challenger'
32
+ s.add_development_dependency 'rubocop-rails'
33
+ s.add_development_dependency 'rubocop-rspec'
34
+ s.add_development_dependency 'rubocop-performance'
35
+ s.add_development_dependency "simplecov"
36
+ s.add_development_dependency "sqlite3"
28
37
  end
@@ -34,17 +34,17 @@ module Apipie
34
34
 
35
35
  @language = get_language
36
36
 
37
- Apipie.load_documentation if Apipie.configuration.reload_controllers? || (Rails.version.to_i >= 4.0 && !Rails.application.config.eager_load)
37
+ Apipie.load_documentation if Apipie.configuration.reload_controllers? || !Rails.application.config.eager_load
38
38
 
39
39
  I18n.locale = @language
40
40
 
41
41
  if should_render_swagger
42
- prev_warning_value = Apipie.configuration.swagger_suppress_warnings
42
+ prev_warning_value = Apipie.configuration.generator.swagger.suppress_warnings
43
43
  begin
44
- Apipie.configuration.swagger_suppress_warnings = true
44
+ Apipie.configuration.generator.swagger.suppress_warnings = true
45
45
  @doc = Apipie.to_swagger_json(params[:version], params[:resource], params[:method], @language)
46
46
  ensure
47
- Apipie.configuration.swagger_suppress_warnings = prev_warning_value
47
+ Apipie.configuration.generator.swagger.suppress_warnings = prev_warning_value
48
48
  end
49
49
  else
50
50
  @doc = Apipie.to_json(params[:version], params[:resource], params[:method], @language)
@@ -98,12 +98,11 @@ module Apipie
98
98
  return nil unless Apipie.configuration.translate
99
99
  lang = Apipie.configuration.default_locale
100
100
  [:resource, :method, :version].each do |par|
101
- if params[par]
102
- splitted = params[par].split('.')
103
- if splitted.length > 1 && Apipie.configuration.languages.include?(splitted.last)
104
- lang = splitted.last
105
- params[par].sub!(".#{lang}", '')
106
- end
101
+ next unless params[par]
102
+ splitted = params[par].split('.')
103
+ if splitted.length > 1 && (Apipie.configuration.languages.include?(splitted.last) || Apipie.configuration.default_locale == splitted.last)
104
+ lang = splitted.last
105
+ params[par].sub!(".#{lang}", '')
107
106
  end
108
107
  end
109
108
  lang
@@ -120,7 +119,7 @@ module Apipie
120
119
  authorize_resource(resource)
121
120
  end
122
121
  else
123
- @doc[:docs][:resources].select do |_resource_name, resource|
122
+ @doc[:docs][:resources].select do |_resource_id, resource|
124
123
  authorize_resource(resource)
125
124
  end
126
125
  end
@@ -155,29 +154,15 @@ module Apipie
155
154
 
156
155
  def render_from_cache
157
156
  path = Apipie.configuration.doc_base_url.dup
158
- # some params can contain dot, but only one in row
159
- if [:resource, :method, :format, :version].any? { |p| params[p].to_s.gsub(".", "") =~ /\W/ || params[p].to_s =~ /\.\./ }
160
- head :bad_request and return
161
- end
162
-
163
157
  path << "/" << params[:version] if params[:version].present?
164
158
  path << "/" << params[:resource] if params[:resource].present?
165
159
  path << "/" << params[:method] if params[:method].present?
166
- if params[:format].present?
167
- path << ".#{params[:format]}"
168
- else
169
- path << ".html"
170
- end
171
-
172
- # we sanitize the params before so in ideal case, this condition
173
- # will be never satisfied. It's here for cases somebody adds new
174
- # param into the path later and forgets about sanitation.
175
- if path =~ /\.\./
176
- head :bad_request and return
177
- end
160
+ # Sanitize path against directory traversal attacks (e.g. ../../foo)
161
+ # by turning path into an absolute path before appending it to the cache dir
162
+ path = File.expand_path("#{path}.#{request.format.symbol}", '/')
178
163
 
179
164
  cache_file = File.join(Apipie.configuration.cache_dir, path)
180
- if File.exists?(cache_file)
165
+ if File.exist?(cache_file)
181
166
  content_type = case params[:format]
182
167
  when "json" then "application/json"
183
168
  else "text/html"
@@ -1,7 +1,7 @@
1
1
  module ApipieHelper
2
2
  include ActionView::Helpers::TagHelper
3
3
 
4
- def heading(title, level=1)
4
+ def heading(title, level = 1)
5
5
  content_tag("h#{level}") do
6
6
  title
7
7
  end