apipie-rails 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rubocop.yml +2 -2
  3. data/.rubocop.yml +15 -0
  4. data/.rubocop_todo.yml +3 -276
  5. data/CHANGELOG.md +6 -0
  6. data/app/controllers/apipie/apipies_controller.rb +2 -2
  7. data/app/helpers/apipie_helper.rb +1 -1
  8. data/lib/apipie/apipie_module.rb +2 -2
  9. data/lib/apipie/application.rb +12 -2
  10. data/lib/apipie/dsl_definition.rb +4 -4
  11. data/lib/apipie/error_description.rb +1 -1
  12. data/lib/apipie/errors.rb +2 -16
  13. data/lib/apipie/extractor/collector.rb +1 -1
  14. data/lib/apipie/extractor/recorder.rb +1 -1
  15. data/lib/apipie/extractor.rb +1 -1
  16. data/lib/apipie/generator/swagger/operation_id.rb +1 -1
  17. data/lib/apipie/helpers.rb +3 -3
  18. data/lib/apipie/method_description.rb +1 -1
  19. data/lib/apipie/resource_description.rb +10 -7
  20. data/lib/apipie/response_description.rb +1 -1
  21. data/lib/apipie/response_description_adapter.rb +3 -3
  22. data/lib/apipie/routing.rb +1 -1
  23. data/lib/apipie/rspec/response_validation_helper.rb +1 -1
  24. data/lib/apipie/swagger_generator.rb +6 -6
  25. data/lib/apipie/validator.rb +2 -2
  26. data/lib/apipie/version.rb +1 -1
  27. data/lib/tasks/apipie.rake +10 -10
  28. data/spec/dummy/config.ru +1 -1
  29. data/spec/lib/apipie/apipies_controller_spec.rb +4 -0
  30. data/spec/lib/apipie/application_spec.rb +16 -15
  31. data/spec/lib/apipie/generator/swagger/context_spec.rb +1 -0
  32. data/spec/lib/apipie/no_documented_method_spec.rb +17 -0
  33. data/spec/lib/apipie/resource_description_spec.rb +71 -28
  34. data/spec/lib/apipie/response_does_not_match_swagger_schema_spec.rb +35 -0
  35. data/spec/lib/rake_spec.rb +1 -1
  36. data/spec/lib/swagger/rake_swagger_spec.rb +2 -2
  37. data/spec/lib/swagger/swagger_dsl_spec.rb +10 -4
  38. data/spec/spec_helper.rb +2 -2
  39. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c985a0a0a96f041421d812221f6352f69fb32eb93ec6a6bb4a990b2151a39f8
4
- data.tar.gz: 3d21ade5a4dfb08bc0faaf5c46fa8fe5e7cf294f14d9ee637c3e019b522f5bbf
3
+ metadata.gz: 6b80c8d9148eb30ad409dcbd396a7b48a55f168c9f64f3dbc699bf11ba2f5a71
4
+ data.tar.gz: 7530489978c584ec75e533c913acf179a76ed0b6ee9c8fa5a0947f8c163cb07d
5
5
  SHA512:
6
- metadata.gz: 907ba718cd32695e13ce42203d639891de031221f90475712b2c7e816b1db7304174922ea796d2a31cdc4050f768871b06c3e9efc968e4db447400531ad0ca45
7
- data.tar.gz: 234ba3b4eab287d9530e09ae28c79821a509c4c57f8b42b1bf2da83d93141d3fb807c88cef97d9a889c4e4b1a70a94d41f92a2f5c6bf0e79f8c9ad3a65aa9f50
6
+ metadata.gz: 2c1fd67f999a263c2d1655eaf5e7424ef7c98b6bb269b9f54ace1f201cad01447f769dc2ec83ba3d8ec60057f28ee2661e849061a22af49514fd03f1cbc7d75f
7
+ data.tar.gz: 7fbdd5e6bd529f66327346986ec8ba093518b1e94281da7a4f72c05cc00d1b64090736f70681b1142a9489fbb0f41a1956d9ef72b3f7b65694d8c59fa0831cc0
@@ -10,10 +10,10 @@ jobs:
10
10
  steps:
11
11
  - uses: actions/checkout@v3
12
12
 
13
- - name: Set up Ruby 2.7
13
+ - name: Set up Ruby 3.2.1
14
14
  uses: ruby/setup-ruby@v1
15
15
  with:
16
- ruby-version: 2.7
16
+ ruby-version: 3.2.1
17
17
  bundler-cache: true
18
18
 
19
19
  - name: Run rubocop
data/.rubocop.yml CHANGED
@@ -55,6 +55,9 @@ Naming/PredicateName:
55
55
  AllowedMethods:
56
56
  - have_field?
57
57
 
58
+ Style/IfUnlessModifier:
59
+ Enabled: false
60
+
58
61
  Style/NumericPredicate:
59
62
  Enabled: false
60
63
 
@@ -113,6 +116,18 @@ Style/Documentation:
113
116
  - spec/lib/validators/array_validator_spec.rb
114
117
  - spec/dummy/**/*.rb
115
118
 
119
+ Style/FrozenStringLiteralComment:
120
+ Enabled: false
121
+
122
+ Style/InverseMethods:
123
+ Enabled: false
124
+
116
125
  Naming/BlockForwarding:
117
126
  EnforcedStyle: explicit
118
127
  BlockForwardingName: block
128
+
129
+ Lint/MissingSuper:
130
+ Exclude:
131
+ - 'lib/apipie/errors.rb'
132
+ - 'lib/apipie/response_description_adapter.rb'
133
+ - 'lib/apipie/validator.rb'
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config --exclude-limit 180`
3
- # on 2023-03-06 23:34:08 UTC using RuboCop version 1.48.0.
3
+ # on 2023-04-03 23:33:58 UTC using RuboCop version 1.49.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -521,33 +521,6 @@ Layout/SpaceAfterNot:
521
521
  - 'lib/apipie/extractor/collector.rb'
522
522
  - 'lib/apipie/extractor/writer.rb'
523
523
 
524
- # Offense count: 35
525
- # This cop supports safe autocorrection (--autocorrect).
526
- # Configuration parameters: EnforcedStyle.
527
- # SupportedStyles: space, no_space
528
- Layout/SpaceAroundEqualsInParameterDefault:
529
- Exclude:
530
- - 'app/helpers/apipie_helper.rb'
531
- - 'lib/apipie/apipie_module.rb'
532
- - 'lib/apipie/application.rb'
533
- - 'lib/apipie/dsl_definition.rb'
534
- - 'lib/apipie/error_description.rb'
535
- - 'lib/apipie/method_description.rb'
536
- - 'lib/apipie/response_description.rb'
537
- - 'lib/apipie/response_description_adapter.rb'
538
- - 'lib/apipie/rspec/response_validation_helper.rb'
539
- - 'lib/apipie/swagger_generator.rb'
540
- - 'lib/apipie/validator.rb'
541
- - 'lib/tasks/apipie.rake'
542
- - 'spec/lib/swagger/swagger_dsl_spec.rb'
543
- - 'spec/spec_helper.rb'
544
-
545
- # Offense count: 1
546
- # This cop supports safe autocorrection (--autocorrect).
547
- Layout/SpaceAroundMethodCallOperator:
548
- Exclude:
549
- - 'lib/apipie/validator.rb'
550
-
551
524
  # Offense count: 142
552
525
  # This cop supports safe autocorrection (--autocorrect).
553
526
  # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
@@ -738,13 +711,6 @@ Lint/IdentityComparison:
738
711
  Exclude:
739
712
  - 'spec/lib/swagger/swagger_dsl_spec.rb'
740
713
 
741
- # Offense count: 5
742
- Lint/MissingSuper:
743
- Exclude:
744
- - 'lib/apipie/errors.rb'
745
- - 'lib/apipie/response_description_adapter.rb'
746
- - 'lib/apipie/validator.rb'
747
-
748
714
  # Offense count: 11
749
715
  # This cop supports unsafe autocorrection (--autocorrect-all).
750
716
  Lint/NonAtomicFileOperation:
@@ -998,11 +964,10 @@ Performance/RedundantMerge:
998
964
  - 'lib/apipie/generator/swagger/param_description/type.rb'
999
965
  - 'lib/apipie/middleware/checksum_in_headers.rb'
1000
966
 
1001
- # Offense count: 8
967
+ # Offense count: 7
1002
968
  # This cop supports safe autocorrection (--autocorrect).
1003
969
  Performance/RegexpMatch:
1004
970
  Exclude:
1005
- - 'app/controllers/apipie/apipies_controller.rb'
1006
971
  - 'lib/apipie/extractor/writer.rb'
1007
972
  - 'lib/apipie/helpers.rb'
1008
973
 
@@ -1014,12 +979,6 @@ Performance/StringIdentifierArgument:
1014
979
  - 'spec/controllers/users_controller_spec.rb'
1015
980
  - 'spec/lib/apipie/method_description_spec.rb'
1016
981
 
1017
- # Offense count: 2
1018
- # This cop supports unsafe autocorrection (--autocorrect-all).
1019
- Performance/StringInclude:
1020
- Exclude:
1021
- - 'app/controllers/apipie/apipies_controller.rb'
1022
-
1023
982
  # Offense count: 7
1024
983
  # This cop supports safe autocorrection (--autocorrect).
1025
984
  Performance/StringReplacement:
@@ -1121,15 +1080,6 @@ RSpec/EmptyExampleGroup:
1121
1080
  Exclude:
1122
1081
  - 'spec/lib/apipie/generator/swagger/param_description/composite_spec.rb'
1123
1082
 
1124
- # Offense count: 11
1125
- # This cop supports safe autocorrection (--autocorrect).
1126
- # Configuration parameters: AllowConsecutiveOneLiners.
1127
- RSpec/EmptyLineAfterExample:
1128
- Exclude:
1129
- - 'spec/lib/apipie/apipies_controller_spec.rb'
1130
- - 'spec/lib/apipie/generator/swagger/context_spec.rb'
1131
- - 'spec/lib/swagger/swagger_dsl_spec.rb'
1132
-
1133
1083
  # Offense count: 6
1134
1084
  # This cop supports safe autocorrection (--autocorrect).
1135
1085
  RSpec/EmptyLineAfterExampleGroup:
@@ -1254,7 +1204,7 @@ RSpec/MessageSpies:
1254
1204
  RSpec/MultipleExpectations:
1255
1205
  Max: 19
1256
1206
 
1257
- # Offense count: 64
1207
+ # Offense count: 66
1258
1208
  # Configuration parameters: AllowSubject.
1259
1209
  RSpec/MultipleMemoizedHelpers:
1260
1210
  Max: 15
@@ -1479,14 +1429,6 @@ Rails/RootPathnameMethods:
1479
1429
  - 'spec/lib/rake_spec.rb'
1480
1430
  - 'spec/lib/swagger/rake_swagger_spec.rb'
1481
1431
 
1482
- # Offense count: 4
1483
- # This cop supports unsafe autocorrection (--autocorrect-all).
1484
- # Configuration parameters: EnforcedStyle.
1485
- # SupportedStyles: strict, flexible
1486
- Rails/TimeZone:
1487
- Exclude:
1488
- - 'lib/tasks/apipie.rake'
1489
-
1490
1432
  # Offense count: 1
1491
1433
  # This cop supports unsafe autocorrection (--autocorrect-all).
1492
1434
  Security/IoMethods:
@@ -1720,153 +1662,6 @@ Style/For:
1720
1662
  Style/FormatStringToken:
1721
1663
  EnforcedStyle: template
1722
1664
 
1723
- # Offense count: 140
1724
- # This cop supports unsafe autocorrection (--autocorrect-all).
1725
- # Configuration parameters: EnforcedStyle.
1726
- # SupportedStyles: always, always_true, never
1727
- Style/FrozenStringLiteralComment:
1728
- Exclude:
1729
- - 'Rakefile'
1730
- - 'apipie-rails.gemspec'
1731
- - 'app/controllers/apipie/apipies_controller.rb'
1732
- - 'app/helpers/apipie_helper.rb'
1733
- - 'lib/apipie-rails.rb'
1734
- - 'lib/apipie/apipie_module.rb'
1735
- - 'lib/apipie/application.rb'
1736
- - 'lib/apipie/configuration.rb'
1737
- - 'lib/apipie/core_ext/route.rb'
1738
- - 'lib/apipie/dsl_definition.rb'
1739
- - 'lib/apipie/error_description.rb'
1740
- - 'lib/apipie/errors.rb'
1741
- - 'lib/apipie/extractor.rb'
1742
- - 'lib/apipie/extractor/collector.rb'
1743
- - 'lib/apipie/extractor/recorder.rb'
1744
- - 'lib/apipie/extractor/writer.rb'
1745
- - 'lib/apipie/generator/generator.rb'
1746
- - 'lib/apipie/generator/swagger/context.rb'
1747
- - 'lib/apipie/generator/swagger/operation_id.rb'
1748
- - 'lib/apipie/generator/swagger/param_description.rb'
1749
- - 'lib/apipie/generator/swagger/param_description/builder.rb'
1750
- - 'lib/apipie/generator/swagger/param_description/composite.rb'
1751
- - 'lib/apipie/generator/swagger/param_description/description.rb'
1752
- - 'lib/apipie/generator/swagger/param_description/in.rb'
1753
- - 'lib/apipie/generator/swagger/param_description/name.rb'
1754
- - 'lib/apipie/generator/swagger/param_description/type.rb'
1755
- - 'lib/apipie/generator/swagger/swagger.rb'
1756
- - 'lib/apipie/generator/swagger/type.rb'
1757
- - 'lib/apipie/generator/swagger/type_extractor.rb'
1758
- - 'lib/apipie/generator/swagger/warning.rb'
1759
- - 'lib/apipie/generator/swagger/warning_writer.rb'
1760
- - 'lib/apipie/helpers.rb'
1761
- - 'lib/apipie/markup.rb'
1762
- - 'lib/apipie/method_description.rb'
1763
- - 'lib/apipie/method_description/api.rb'
1764
- - 'lib/apipie/method_description/apis_service.rb'
1765
- - 'lib/apipie/middleware/checksum_in_headers.rb'
1766
- - 'lib/apipie/param_description.rb'
1767
- - 'lib/apipie/railtie.rb'
1768
- - 'lib/apipie/resource_description.rb'
1769
- - 'lib/apipie/response_description.rb'
1770
- - 'lib/apipie/response_description_adapter.rb'
1771
- - 'lib/apipie/routes_formatter.rb'
1772
- - 'lib/apipie/routing.rb'
1773
- - 'lib/apipie/rspec/response_validation_helper.rb'
1774
- - 'lib/apipie/see_description.rb'
1775
- - 'lib/apipie/static_dispatcher.rb'
1776
- - 'lib/apipie/swagger_generator.rb'
1777
- - 'lib/apipie/tag_list_description.rb'
1778
- - 'lib/apipie/validator.rb'
1779
- - 'lib/apipie/version.rb'
1780
- - 'lib/generators/apipie/install/install_generator.rb'
1781
- - 'lib/generators/apipie/views_generator.rb'
1782
- - 'lib/tasks/apipie.rake'
1783
- - 'spec/controllers/api/v1/architectures_controller_spec.rb'
1784
- - 'spec/controllers/api/v2/architectures_controller_spec.rb'
1785
- - 'spec/controllers/api/v2/nested/resources_controller_spec.rb'
1786
- - 'spec/controllers/concerns_controller_spec.rb'
1787
- - 'spec/controllers/extended_controller_spec.rb'
1788
- - 'spec/controllers/included_param_group_controller_spec.rb'
1789
- - 'spec/controllers/pets_controller_spec.rb'
1790
- - 'spec/controllers/users_controller_spec.rb'
1791
- - 'spec/dummy/Rakefile'
1792
- - 'spec/dummy/app/controllers/api/base_controller.rb'
1793
- - 'spec/dummy/app/controllers/api/v1/architectures_controller.rb'
1794
- - 'spec/dummy/app/controllers/api/v1/base_controller.rb'
1795
- - 'spec/dummy/app/controllers/api/v2/architectures_controller.rb'
1796
- - 'spec/dummy/app/controllers/api/v2/base_controller.rb'
1797
- - 'spec/dummy/app/controllers/api/v2/nested/architectures_controller.rb'
1798
- - 'spec/dummy/app/controllers/api/v2/nested/resources_controller.rb'
1799
- - 'spec/dummy/app/controllers/application_controller.rb'
1800
- - 'spec/dummy/app/controllers/concerns_controller.rb'
1801
- - 'spec/dummy/app/controllers/extended_controller.rb'
1802
- - 'spec/dummy/app/controllers/extending_concern.rb'
1803
- - 'spec/dummy/app/controllers/files_controller.rb'
1804
- - 'spec/dummy/app/controllers/included_param_group_controller.rb'
1805
- - 'spec/dummy/app/controllers/overridden_concerns_controller.rb'
1806
- - 'spec/dummy/app/controllers/pets_controller.rb'
1807
- - 'spec/dummy/app/controllers/pets_using_auto_views_controller.rb'
1808
- - 'spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb'
1809
- - 'spec/dummy/app/controllers/sample_controller.rb'
1810
- - 'spec/dummy/app/controllers/tagged_cats_controller.rb'
1811
- - 'spec/dummy/app/controllers/tagged_dogs_controller.rb'
1812
- - 'spec/dummy/app/controllers/twitter_example_controller.rb'
1813
- - 'spec/dummy/app/controllers/users_controller.rb'
1814
- - 'spec/dummy/app/helpers/random_param_group.rb'
1815
- - 'spec/dummy/components/test_engine/Gemfile'
1816
- - 'spec/dummy/components/test_engine/app/controllers/test_engine/application_controller.rb'
1817
- - 'spec/dummy/components/test_engine/app/controllers/test_engine/memes_controller.rb'
1818
- - 'spec/dummy/components/test_engine/config/routes.rb'
1819
- - 'spec/dummy/components/test_engine/lib/test_engine.rb'
1820
- - 'spec/dummy/components/test_engine/test_engine.gemspec'
1821
- - 'spec/dummy/config.ru'
1822
- - 'spec/dummy/config/application.rb'
1823
- - 'spec/dummy/config/boot.rb'
1824
- - 'spec/dummy/config/environment.rb'
1825
- - 'spec/dummy/config/environments/development.rb'
1826
- - 'spec/dummy/config/environments/production.rb'
1827
- - 'spec/dummy/config/environments/test.rb'
1828
- - 'spec/dummy/config/initializers/apipie.rb'
1829
- - 'spec/dummy/config/initializers/backtrace_silencers.rb'
1830
- - 'spec/dummy/config/initializers/inflections.rb'
1831
- - 'spec/dummy/config/initializers/mime_types.rb'
1832
- - 'spec/dummy/config/initializers/secret_token.rb'
1833
- - 'spec/dummy/config/initializers/session_store.rb'
1834
- - 'spec/dummy/config/routes.rb'
1835
- - 'spec/dummy/script/rails'
1836
- - 'spec/lib/apipie/apipies_controller_spec.rb'
1837
- - 'spec/lib/apipie/application_spec.rb'
1838
- - 'spec/lib/apipie/extractor/recorder/middleware_spec.rb'
1839
- - 'spec/lib/apipie/extractor/writer_spec.rb'
1840
- - 'spec/lib/apipie/extractor_spec.rb'
1841
- - 'spec/lib/apipie/file_handler_spec.rb'
1842
- - 'spec/lib/apipie/generator/swagger/context_spec.rb'
1843
- - 'spec/lib/apipie/generator/swagger/operation_id_spec.rb'
1844
- - 'spec/lib/apipie/generator/swagger/param_description/builder_spec.rb'
1845
- - 'spec/lib/apipie/generator/swagger/param_description/composite_spec.rb'
1846
- - 'spec/lib/apipie/generator/swagger/param_description/description_spec.rb'
1847
- - 'spec/lib/apipie/generator/swagger/param_description/in_spec.rb'
1848
- - 'spec/lib/apipie/generator/swagger/param_description/name_spec.rb'
1849
- - 'spec/lib/apipie/generator/swagger/param_description/type_spec.rb'
1850
- - 'spec/lib/apipie/generator/swagger/param_description_spec.rb'
1851
- - 'spec/lib/apipie/generator/swagger/type_extractor_spec.rb'
1852
- - 'spec/lib/apipie/generator/swagger/warning_spec.rb'
1853
- - 'spec/lib/apipie/generator/swagger/warning_writer_spec.rb'
1854
- - 'spec/lib/apipie/method_description/apis_service_spec.rb'
1855
- - 'spec/lib/apipie/method_description_spec.rb'
1856
- - 'spec/lib/apipie/param_description/deprecation_spec.rb'
1857
- - 'spec/lib/apipie/param_description_spec.rb'
1858
- - 'spec/lib/apipie/param_group_spec.rb'
1859
- - 'spec/lib/apipie/resource_description_spec.rb'
1860
- - 'spec/lib/apipie/validator_spec.rb'
1861
- - 'spec/lib/rake_spec.rb'
1862
- - 'spec/lib/swagger/rake_swagger_spec.rb'
1863
- - 'spec/lib/swagger/swagger_dsl_spec.rb'
1864
- - 'spec/lib/validators/array_validator_spec.rb'
1865
- - 'spec/spec_helper.rb'
1866
- - 'spec/support/custom_bool_validator.rb'
1867
- - 'spec/support/rake.rb'
1868
- - 'spec/test_engine/memes_controller_spec.rb'
1869
-
1870
1665
  # Offense count: 34
1871
1666
  # This cop supports safe autocorrection (--autocorrect).
1872
1667
  # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
@@ -1920,35 +1715,6 @@ Style/IfInsideElse:
1920
1715
  - 'lib/apipie/swagger_generator.rb'
1921
1716
  - 'spec/spec_helper.rb'
1922
1717
 
1923
- # Offense count: 73
1924
- # This cop supports safe autocorrection (--autocorrect).
1925
- Style/IfUnlessModifier:
1926
- Exclude:
1927
- - 'app/controllers/apipie/apipies_controller.rb'
1928
- - 'lib/apipie/application.rb'
1929
- - 'lib/apipie/dsl_definition.rb'
1930
- - 'lib/apipie/extractor.rb'
1931
- - 'lib/apipie/extractor/collector.rb'
1932
- - 'lib/apipie/extractor/writer.rb'
1933
- - 'lib/apipie/generator/swagger/param_description/composite.rb'
1934
- - 'lib/apipie/generator/swagger/param_description/type.rb'
1935
- - 'lib/apipie/generator/swagger/type_extractor.rb'
1936
- - 'lib/apipie/generator/swagger/warning.rb'
1937
- - 'lib/apipie/method_description.rb'
1938
- - 'lib/apipie/param_description.rb'
1939
- - 'lib/apipie/resource_description.rb'
1940
- - 'lib/apipie/routes_formatter.rb'
1941
- - 'lib/apipie/rspec/response_validation_helper.rb'
1942
- - 'lib/apipie/see_description.rb'
1943
- - 'lib/apipie/swagger_generator.rb'
1944
- - 'lib/apipie/validator.rb'
1945
- - 'lib/tasks/apipie.rake'
1946
- - 'spec/dummy/app/controllers/application_controller.rb'
1947
- - 'spec/dummy/app/controllers/users_controller.rb'
1948
- - 'spec/dummy/config/initializers/apipie.rb'
1949
- - 'spec/lib/swagger/swagger_dsl_spec.rb'
1950
- - 'spec/spec_helper.rb'
1951
-
1952
1718
  # Offense count: 4
1953
1719
  # This cop supports unsafe autocorrection (--autocorrect-all).
1954
1720
  # Configuration parameters: AllowedMethods.
@@ -1959,20 +1725,6 @@ Style/IfWithBooleanLiteralBranches:
1959
1725
  - 'lib/apipie/validator.rb'
1960
1726
  - 'lib/tasks/apipie.rake'
1961
1727
 
1962
- # Offense count: 13
1963
- # This cop supports unsafe autocorrection (--autocorrect-all).
1964
- # Configuration parameters: InverseMethods, InverseBlocks.
1965
- Style/InverseMethods:
1966
- Exclude:
1967
- - 'lib/apipie/configuration.rb'
1968
- - 'lib/apipie/extractor/collector.rb'
1969
- - 'lib/apipie/extractor/writer.rb'
1970
- - 'lib/apipie/generator/swagger/warning.rb'
1971
- - 'lib/apipie/method_description.rb'
1972
- - 'lib/apipie/param_description.rb'
1973
- - 'lib/apipie/swagger_generator.rb'
1974
- - 'spec/spec_helper.rb'
1975
-
1976
1728
  # Offense count: 5
1977
1729
  # This cop supports safe autocorrection (--autocorrect).
1978
1730
  # Configuration parameters: EnforcedStyle.
@@ -2146,16 +1898,6 @@ Style/RedundantConditional:
2146
1898
  - 'lib/apipie/validator.rb'
2147
1899
  - 'lib/tasks/apipie.rake'
2148
1900
 
2149
- # Offense count: 9
2150
- # This cop supports safe autocorrection (--autocorrect).
2151
- Style/RedundantConstantBase:
2152
- Exclude:
2153
- - 'lib/tasks/apipie.rake'
2154
- - 'spec/dummy/config.ru'
2155
- - 'spec/lib/rake_spec.rb'
2156
- - 'spec/lib/swagger/rake_swagger_spec.rb'
2157
- - 'spec/spec_helper.rb'
2158
-
2159
1901
  # Offense count: 5
2160
1902
  # This cop supports unsafe autocorrection (--autocorrect-all).
2161
1903
  Style/RedundantInterpolation:
@@ -2219,21 +1961,6 @@ Style/RedundantStringEscape:
2219
1961
  Exclude:
2220
1962
  - 'spec/dummy/app/controllers/users_controller.rb'
2221
1963
 
2222
- # Offense count: 12
2223
- # This cop supports safe autocorrection (--autocorrect).
2224
- # Configuration parameters: EnforcedStyle, AllowInnerSlashes.
2225
- # SupportedStyles: slashes, percent_r, mixed
2226
- Style/RegexpLiteral:
2227
- Exclude:
2228
- - 'lib/apipie/extractor.rb'
2229
- - 'lib/apipie/extractor/collector.rb'
2230
- - 'lib/apipie/extractor/recorder.rb'
2231
- - 'lib/apipie/generator/swagger/operation_id.rb'
2232
- - 'lib/apipie/helpers.rb'
2233
- - 'lib/apipie/routing.rb'
2234
- - 'lib/apipie/swagger_generator.rb'
2235
- - 'lib/tasks/apipie.rake'
2236
-
2237
1964
  # Offense count: 1
2238
1965
  # This cop supports safe autocorrection (--autocorrect).
2239
1966
  # Configuration parameters: EnforcedStyle.
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@
4
4
  Also deleted the `Gemfile` that was now a broken symlink.
5
5
  please use `export BUNDLE_GEMFILE='gemfiles/Gemfile.rails61'; bundle exec rspec` to run the test suite
6
6
 
7
+ ## [v0.9.4](https://github.com/Apipie/apipie-rails/tree/v0.9.4) (2023-04-11)
8
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.9.3...v0.9.4)
9
+ * [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)
10
+ * [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)
11
+ * [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)
12
+
7
13
  ## [v0.9.3](https://github.com/Apipie/apipie-rails/tree/v0.9.3) (2023-03-08)
8
14
  [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.9.2...v0.9.3)
9
15
  * [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)
@@ -155,7 +155,7 @@ module Apipie
155
155
  def render_from_cache
156
156
  path = Apipie.configuration.doc_base_url.dup
157
157
  # some params can contain dot, but only one in row
158
- if [:resource, :method, :format, :version].any? { |p| params[p].to_s.gsub(".", "") =~ /\W/ || params[p].to_s =~ /\.\./ }
158
+ if [:resource, :method, :format, :version].any? { |p| params[p].to_s.gsub(".", "") =~ /\W/ || params[p].to_s.include?('..') }
159
159
  head :bad_request and return
160
160
  end
161
161
 
@@ -171,7 +171,7 @@ module Apipie
171
171
  # we sanitize the params before so in ideal case, this condition
172
172
  # will be never satisfied. It's here for cases somebody adds new
173
173
  # param into the path later and forgets about sanitation.
174
- if path =~ /\.\./
174
+ if path.include?('..')
175
175
  head :bad_request and return
176
176
  end
177
177
 
@@ -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
@@ -13,7 +13,7 @@ module Apipie
13
13
  app.to_json(version, resource_name, method_name, lang)
14
14
  end
15
15
 
16
- def self.to_swagger_json(version = nil, resource_name = nil, method_name = nil, lang = nil, clear_warnings=true)
16
+ def self.to_swagger_json(version = nil, resource_name = nil, method_name = nil, lang = nil, clear_warnings = true)
17
17
  version ||= Apipie.configuration.default_version
18
18
  app.to_swagger_json(version, resource_name, method_name, lang, clear_warnings)
19
19
  end
@@ -24,7 +24,7 @@ module Apipie
24
24
  app.json_schema_for_method_response(version, controller_name, method_name, return_code, allow_nulls)
25
25
  end
26
26
 
27
- def self.json_schema_for_self_describing_class(cls, allow_nulls=true)
27
+ def self.json_schema_for_self_describing_class(cls, allow_nulls = true)
28
28
  app.json_schema_for_self_describing_class(cls, allow_nulls)
29
29
  end
30
30
 
@@ -268,7 +268,7 @@ module Apipie
268
268
  @swagger_generator.json_schema_for_self_describing_class(cls, allow_nulls)
269
269
  end
270
270
 
271
- def to_swagger_json(version, resource_name, method_name, lang, clear_warnings=false)
271
+ def to_swagger_json(version, resource_name, method_name, lang, clear_warnings = false)
272
272
  return unless valid_search_args?(version, resource_name, method_name)
273
273
 
274
274
  # if resource_name is blank, take just resources which have some methods because
@@ -375,8 +375,18 @@ module Apipie
375
375
  @controller_to_resource_id[klass]
376
376
  elsif Apipie.configuration.namespaced_resources? && klass.respond_to?(:controller_path)
377
377
  return nil if klass == ActionController::Base
378
+
379
+ version_prefix = version_prefix(klass)
378
380
  path = klass.controller_path
379
- path.gsub(version_prefix(klass), "").gsub("/", "-")
381
+
382
+ path =
383
+ if version_prefix == '/'
384
+ path
385
+ else
386
+ path.gsub(version_prefix, '')
387
+ end
388
+
389
+ path.gsub('/', '-')
380
390
  elsif klass.respond_to?(:controller_name)
381
391
  return nil if klass == ActionController::Base
382
392
  klass.controller_name
@@ -96,7 +96,7 @@ module Apipie
96
96
  # # load paths from routes and don't provide description
97
97
  # api
98
98
  #
99
- def api(method, path, desc = nil, options={}) #:doc:
99
+ def api(method, path, desc = nil, options = {}) #:doc:
100
100
  return unless Apipie.active_dsl?
101
101
  _apipie_dsl_data[:api] = true
102
102
  _apipie_dsl_data[:api_args] << [method, path, desc, options]
@@ -105,7 +105,7 @@ module Apipie
105
105
  # # load paths from routes
106
106
  # api! "short description",
107
107
  #
108
- def api!(desc = nil, options={}) #:doc:
108
+ def api!(desc = nil, options = {}) #:doc:
109
109
  return unless Apipie.active_dsl?
110
110
  _apipie_dsl_data[:api] = true
111
111
  _apipie_dsl_data[:api_from_routes] = { :desc => desc, :options =>options }
@@ -218,7 +218,7 @@ module Apipie
218
218
  # puts "hello world"
219
219
  # end
220
220
  #
221
- def error(code_or_options, desc=nil, options={}) #:doc:
221
+ def error(code_or_options, desc = nil, options = {}) #:doc:
222
222
  return unless Apipie.active_dsl?
223
223
  _apipie_dsl_data[:errors] << [code_or_options, desc, options]
224
224
  end
@@ -403,7 +403,7 @@ module Apipie
403
403
  # render json: {user: {name: "Alfred"}}
404
404
  # end
405
405
  #
406
- def returns(pgroup_or_options, desc_or_options=nil, options={}, &block) #:doc:
406
+ def returns(pgroup_or_options, desc_or_options = nil, options = {}, &block) #:doc:
407
407
  return unless Apipie.active_dsl?
408
408
 
409
409
 
@@ -10,7 +10,7 @@ module Apipie
10
10
  options)
11
11
  end
12
12
 
13
- def initialize(code_or_options, desc=nil, options={})
13
+ def initialize(code_or_options, desc = nil, options = {})
14
14
  if code_or_options.is_a? Hash
15
15
  code_or_options.symbolize_keys!
16
16
  @code = code_or_options[:code]
data/lib/apipie/errors.rb CHANGED
@@ -60,27 +60,13 @@ module Apipie
60
60
 
61
61
  class ResponseDoesNotMatchSwaggerSchema < Error
62
62
  def initialize(controller_name, method_name, response_code, error_messages, schema, returned_object)
63
- @controller_name = controller_name
64
- @method_name = method_name
65
- @response_code = response_code
66
- @error_messages = error_messages
67
- @schema = schema
68
- @returned_object = returned_object
69
- end
70
-
71
- def to_s
72
- "Response does not match swagger schema (#{@controller_name}##{@method_name} #{@response_code}): #{@error_messages}\nSchema: #{JSON(@schema)}\nReturned object: #{@returned_object}"
63
+ super("Response does not match swagger schema (#{controller_name}##{method_name} #{response_code}): #{error_messages}\nSchema: #{JSON(schema)}\nReturned object: #{returned_object}")
73
64
  end
74
65
  end
75
66
 
76
67
  class NoDocumentedMethod < Error
77
68
  def initialize(controller_name, method_name)
78
- @method_name = method_name
79
- @controller_name = controller_name
80
- end
81
-
82
- def to_s
83
- "There is no documented method #{@controller_name}##{@method_name}"
69
+ super("There is no documented method #{controller_name}##{method_name}")
84
70
  end
85
71
  end
86
72
  end
@@ -96,7 +96,7 @@ module Apipie
96
96
  end
97
97
 
98
98
  def add_routes_info(desc)
99
- api_prefix = Apipie.api_base_url.sub(/\/$/,"")
99
+ api_prefix = Apipie.api_base_url.sub(%r{/$},"")
100
100
  desc[:api] = Apipie::Extractor.apis_from_routes[[desc[:controller].name, desc[:action]]]
101
101
  if desc[:api]
102
102
  desc[:params].each do |name, param|
@@ -9,7 +9,7 @@ module Apipie
9
9
 
10
10
  def analyse_env(env)
11
11
  @verb = env["REQUEST_METHOD"].to_sym
12
- @path = env["PATH_INFO"].sub(/^\/*/,"/")
12
+ @path = env["PATH_INFO"].sub(%r{^/*},"/")
13
13
  @query = env["QUERY_STRING"] unless env["QUERY_STRING"].blank?
14
14
  @params = Rack::Utils.parse_nested_query(@query)
15
15
  @params.merge!(env["action_dispatch.request.request_parameters"] || {})
@@ -81,7 +81,7 @@ module Apipie
81
81
  def apis_from_routes
82
82
  return @apis_from_routes if @apis_from_routes
83
83
 
84
- @api_prefix = Apipie.api_base_url.sub(/\/$/,"")
84
+ @api_prefix = Apipie.api_base_url.sub(%r{/$},"")
85
85
  populate_api_routes
86
86
  update_api_descriptions
87
87
 
@@ -37,7 +37,7 @@ class Apipie::Generator::Swagger::OperationId
37
37
  #
38
38
  # @return [String]
39
39
  def path
40
- @path.gsub(/\//, '_').gsub(/:(\w+)/, '\1').gsub(/_$/, '')
40
+ @path.gsub(%r{/}, '_').gsub(/:(\w+)/, '\1').gsub(/_$/, '')
41
41
  end
42
42
 
43
43
  # Converts an http method like `GET` to `get` Using lowercase http method,
@@ -25,10 +25,10 @@ module Apipie
25
25
  @url_prefix << request_script_name
26
26
  @url_prefix << Apipie.configuration.doc_base_url
27
27
  end
28
- path = path.sub(/^\//,"")
28
+ path = path.sub(%r{^/},"")
29
29
  ret = "#{@url_prefix}/#{path}"
30
- ret.insert(0,"/") unless ret =~ /\A[.\/]/
31
- ret.sub!(/\/*\Z/,"")
30
+ ret.insert(0,"/") unless ret =~ %r{\A[./]}
31
+ ret.sub!(%r{/*\Z},"")
32
32
  ret
33
33
  end
34
34
 
@@ -159,7 +159,7 @@ module Apipie
159
159
  @formats || @resource._formats
160
160
  end
161
161
 
162
- def to_json(lang=nil)
162
+ def to_json(lang = nil)
163
163
  {
164
164
  :doc_url => doc_url,
165
165
  :name => @method,