apipie-rails 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +36 -48
- data/CHANGELOG.md +5 -0
- data/lib/apipie/application.rb +6 -6
- data/lib/apipie/generator/swagger/method_description/api_schema_service.rb +2 -2
- data/lib/apipie/generator/swagger/method_description/parameters_service.rb +7 -7
- data/lib/apipie/generator/swagger/param_description/builder.rb +3 -3
- data/lib/apipie/generator/swagger/param_description/path_params_composite.rb +10 -10
- data/lib/apipie/generator/swagger/param_description/type.rb +5 -1
- data/lib/apipie/generator/swagger/resource_description_composite.rb +5 -5
- data/lib/apipie/static_dispatcher.rb +2 -2
- data/lib/apipie/version.rb +1 -1
- data/spec/controllers/pets_controller_spec.rb +1 -1
- data/spec/lib/apipie/generator/swagger/param_description/builder_spec.rb +30 -0
- data/spec/lib/apipie/generator/swagger/param_description/type_spec.rb +29 -2
- data/spec/spec_helper.rb +5 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c72cb8c9744d64b6d940b81e8e692f7794ebce0e4c8438cced6e5e844e7690cb
|
4
|
+
data.tar.gz: 68ffc84b4faf041018bacd00519b071702726035466b6fc44c380bd66de98bcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1de4f529cc90ccf084c4f567576a0db46e51f1aebb470f01818f59479e04847371709ef5e6e05377d9acdd20d39950f27a75b517650f65c29a7d7d460e651884
|
7
|
+
data.tar.gz: 8841db6ef76b1696cbee3f0cafdabbdf3eaca5e94c185604490f7771bbd38bdf6a55c4f720e998558996cca83f70e512dd7e8f9f80c74721d6c11e3dd554c931
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config --exclude-limit 180`
|
3
|
-
# on 2024-
|
3
|
+
# on 2024-07-10 23:53:15 UTC using RuboCop version 1.65.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
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
RubyVersionGlobalsUsage:
|
10
|
-
Exclude:
|
11
|
-
- apipie-rails.gemspec
|
12
|
-
|
13
9
|
# Offense count: 1
|
14
10
|
# This cop supports safe autocorrection (--autocorrect).
|
15
11
|
# Configuration parameters: Severity, Include.
|
@@ -18,7 +14,7 @@ Gemspec/DeprecatedAttributeAssignment:
|
|
18
14
|
Exclude:
|
19
15
|
- 'apipie-rails.gemspec'
|
20
16
|
|
21
|
-
# Offense count:
|
17
|
+
# Offense count: 12
|
22
18
|
# Configuration parameters: EnforcedStyle, AllowedGems, Include.
|
23
19
|
# SupportedStyles: Gemfile, gems.rb, gemspec
|
24
20
|
# Include: **/*.gemspec, **/Gemfile, **/gems.rb
|
@@ -50,6 +46,13 @@ Gemspec/RequiredRubyVersion:
|
|
50
46
|
Exclude:
|
51
47
|
- 'spec/dummy/components/test_engine/test_engine.gemspec'
|
52
48
|
|
49
|
+
# Offense count: 1
|
50
|
+
# Configuration parameters: Severity, Include.
|
51
|
+
# Include: **/*.gemspec
|
52
|
+
Gemspec/RubyVersionGlobalsUsage:
|
53
|
+
Exclude:
|
54
|
+
- 'apipie-rails.gemspec'
|
55
|
+
|
53
56
|
# Offense count: 24
|
54
57
|
# This cop supports safe autocorrection (--autocorrect).
|
55
58
|
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
@@ -142,7 +145,7 @@ Layout/EmptyLineAfterGuardClause:
|
|
142
145
|
- 'spec/lib/swagger/swagger_dsl_spec.rb'
|
143
146
|
- 'spec/spec_helper.rb'
|
144
147
|
|
145
|
-
# Offense count:
|
148
|
+
# Offense count: 12
|
146
149
|
# This cop supports safe autocorrection (--autocorrect).
|
147
150
|
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
|
148
151
|
Layout/EmptyLineBetweenDefs:
|
@@ -158,7 +161,7 @@ Layout/EmptyLineBetweenDefs:
|
|
158
161
|
- 'spec/dummy/app/controllers/pets_using_auto_views_controller.rb'
|
159
162
|
- 'spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb'
|
160
163
|
|
161
|
-
# Offense count:
|
164
|
+
# Offense count: 54
|
162
165
|
# This cop supports safe autocorrection (--autocorrect).
|
163
166
|
Layout/EmptyLines:
|
164
167
|
Exclude:
|
@@ -227,7 +230,7 @@ Layout/EmptyLinesAroundBlockBody:
|
|
227
230
|
- 'spec/spec_helper.rb'
|
228
231
|
- 'spec/test_engine/memes_controller_spec.rb'
|
229
232
|
|
230
|
-
# Offense count:
|
233
|
+
# Offense count: 43
|
231
234
|
# This cop supports safe autocorrection (--autocorrect).
|
232
235
|
# Configuration parameters: EnforcedStyle.
|
233
236
|
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
|
@@ -241,7 +244,6 @@ Layout/EmptyLinesAroundClassBody:
|
|
241
244
|
- 'lib/apipie/markup.rb'
|
242
245
|
- 'lib/apipie/param_description.rb'
|
243
246
|
- 'lib/apipie/resource_description.rb'
|
244
|
-
- 'lib/apipie/response_description.rb'
|
245
247
|
- 'lib/apipie/response_description_adapter.rb'
|
246
248
|
- 'lib/apipie/see_description.rb'
|
247
249
|
- 'lib/apipie/tag_list_description.rb'
|
@@ -415,16 +417,6 @@ Layout/MultilineMethodCallBraceLayout:
|
|
415
417
|
Exclude:
|
416
418
|
- 'lib/tasks/apipie.rake'
|
417
419
|
|
418
|
-
# Offense count: 14
|
419
|
-
# This cop supports safe autocorrection (--autocorrect).
|
420
|
-
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
421
|
-
# SupportedStyles: aligned, indented, indented_relative_to_receiver
|
422
|
-
Layout/MultilineMethodCallIndentation:
|
423
|
-
Exclude:
|
424
|
-
- 'lib/apipie/generator/swagger/param_description/builder.rb'
|
425
|
-
- 'lib/apipie/generator/swagger/param_description/composite.rb'
|
426
|
-
- 'lib/apipie/generator/swagger/param_description/type.rb'
|
427
|
-
|
428
420
|
# Offense count: 4
|
429
421
|
# This cop supports safe autocorrection (--autocorrect).
|
430
422
|
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
@@ -601,12 +593,11 @@ Layout/TrailingEmptyLines:
|
|
601
593
|
- 'spec/lib/apipie/generator/swagger/param_description_spec.rb'
|
602
594
|
- 'spec/lib/apipie/param_group_spec.rb'
|
603
595
|
|
604
|
-
# Offense count:
|
596
|
+
# Offense count: 14
|
605
597
|
# This cop supports safe autocorrection (--autocorrect).
|
606
598
|
# Configuration parameters: AllowInHeredoc.
|
607
599
|
Layout/TrailingWhitespace:
|
608
600
|
Exclude:
|
609
|
-
- 'lib/apipie/error_description.rb'
|
610
601
|
- 'spec/dummy/app/controllers/application_controller.rb'
|
611
602
|
- 'spec/dummy/app/controllers/twitter_example_controller.rb'
|
612
603
|
|
@@ -711,7 +702,7 @@ Lint/UnderscorePrefixedVariableName:
|
|
711
702
|
|
712
703
|
# Offense count: 22
|
713
704
|
# This cop supports safe autocorrection (--autocorrect).
|
714
|
-
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
|
705
|
+
# Configuration parameters: AutoCorrect, IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
|
715
706
|
Lint/UnusedBlockArgument:
|
716
707
|
Exclude:
|
717
708
|
- 'lib/apipie/configuration.rb'
|
@@ -726,7 +717,7 @@ Lint/UnusedBlockArgument:
|
|
726
717
|
|
727
718
|
# Offense count: 24
|
728
719
|
# This cop supports safe autocorrection (--autocorrect).
|
729
|
-
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
|
720
|
+
# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
|
730
721
|
Lint/UnusedMethodArgument:
|
731
722
|
Exclude:
|
732
723
|
- 'lib/apipie/dsl_definition.rb'
|
@@ -737,6 +728,7 @@ Lint/UnusedMethodArgument:
|
|
737
728
|
|
738
729
|
# Offense count: 5
|
739
730
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
731
|
+
# Configuration parameters: AutoCorrect.
|
740
732
|
Lint/UselessAssignment:
|
741
733
|
Exclude:
|
742
734
|
- 'lib/apipie/application.rb'
|
@@ -746,24 +738,26 @@ Lint/UselessAssignment:
|
|
746
738
|
|
747
739
|
# Offense count: 2
|
748
740
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
741
|
+
# Configuration parameters: AutoCorrect.
|
749
742
|
Lint/UselessMethodDefinition:
|
750
743
|
Exclude:
|
751
744
|
- 'spec/dummy/app/controllers/overridden_concerns_controller.rb'
|
752
745
|
|
753
|
-
# Offense count:
|
746
|
+
# Offense count: 4
|
754
747
|
# This cop supports safe autocorrection (--autocorrect).
|
755
|
-
# Configuration parameters: CheckForMethodsWithNoSideEffects.
|
748
|
+
# Configuration parameters: AutoCorrect, CheckForMethodsWithNoSideEffects.
|
756
749
|
Lint/Void:
|
757
750
|
Exclude:
|
758
751
|
- 'spec/controllers/users_controller_spec.rb'
|
752
|
+
- 'spec/lib/swagger/swagger_dsl_spec.rb'
|
759
753
|
|
760
754
|
# Offense count: 60
|
761
755
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
762
756
|
Metrics/AbcSize:
|
763
757
|
Max: 96
|
764
758
|
|
765
|
-
# Offense count:
|
766
|
-
# Configuration parameters: CountBlocks.
|
759
|
+
# Offense count: 1
|
760
|
+
# Configuration parameters: CountBlocks, CountModifierForms.
|
767
761
|
Metrics/BlockNesting:
|
768
762
|
Max: 4
|
769
763
|
|
@@ -977,7 +971,7 @@ RSpec/DescribeClass:
|
|
977
971
|
|
978
972
|
# Offense count: 75
|
979
973
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
980
|
-
# Configuration parameters: SkipBlocks, EnforcedStyle.
|
974
|
+
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
|
981
975
|
# SupportedStyles: described_class, explicit
|
982
976
|
RSpec/DescribedClass:
|
983
977
|
Exclude:
|
@@ -997,6 +991,7 @@ RSpec/DescribedClass:
|
|
997
991
|
|
998
992
|
# Offense count: 1
|
999
993
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
994
|
+
# Configuration parameters: AutoCorrect.
|
1000
995
|
RSpec/EmptyExampleGroup:
|
1001
996
|
Exclude:
|
1002
997
|
- 'spec/lib/apipie/generator/swagger/param_description/composite_spec.rb'
|
@@ -1020,7 +1015,7 @@ RSpec/EmptyLineAfterHook:
|
|
1020
1015
|
Exclude:
|
1021
1016
|
- 'spec/lib/apipie/apipies_controller_spec.rb'
|
1022
1017
|
|
1023
|
-
# Offense count:
|
1018
|
+
# Offense count: 55
|
1024
1019
|
# Configuration parameters: CountAsOne.
|
1025
1020
|
RSpec/ExampleLength:
|
1026
1021
|
Max: 85
|
@@ -1046,6 +1041,7 @@ RSpec/HookArgument:
|
|
1046
1041
|
|
1047
1042
|
# Offense count: 3
|
1048
1043
|
# This cop supports safe autocorrection (--autocorrect).
|
1044
|
+
# Configuration parameters: AutoCorrect.
|
1049
1045
|
RSpec/HooksBeforeExamples:
|
1050
1046
|
Exclude:
|
1051
1047
|
- 'spec/controllers/users_controller_spec.rb'
|
@@ -1092,7 +1088,7 @@ RSpec/MessageSpies:
|
|
1092
1088
|
RSpec/MultipleExpectations:
|
1093
1089
|
Max: 19
|
1094
1090
|
|
1095
|
-
# Offense count:
|
1091
|
+
# Offense count: 170
|
1096
1092
|
# Configuration parameters: AllowSubject.
|
1097
1093
|
RSpec/MultipleMemoizedHelpers:
|
1098
1094
|
Max: 15
|
@@ -1117,7 +1113,7 @@ RSpec/NamedSubject:
|
|
1117
1113
|
- 'spec/lib/swagger/rake_swagger_spec.rb'
|
1118
1114
|
- 'spec/lib/swagger/swagger_dsl_spec.rb'
|
1119
1115
|
|
1120
|
-
# Offense count:
|
1116
|
+
# Offense count: 99
|
1121
1117
|
# Configuration parameters: AllowedGroups.
|
1122
1118
|
RSpec/NestedGroups:
|
1123
1119
|
Max: 6
|
@@ -1156,13 +1152,6 @@ RSpec/PredicateMatcher:
|
|
1156
1152
|
- 'spec/lib/apipie/file_handler_spec.rb'
|
1157
1153
|
- 'spec/lib/swagger/swagger_dsl_spec.rb'
|
1158
1154
|
|
1159
|
-
# Offense count: 1
|
1160
|
-
# This cop supports unsafe autocorrection (--autocorrect-all).
|
1161
|
-
# Configuration parameters: Inferences.
|
1162
|
-
RSpecRails/InferredSpecType:
|
1163
|
-
Exclude:
|
1164
|
-
- 'spec/controllers/pets_controller_spec.rb'
|
1165
|
-
|
1166
1155
|
# Offense count: 2
|
1167
1156
|
RSpec/RepeatedExampleGroupBody:
|
1168
1157
|
Exclude:
|
@@ -1209,7 +1198,7 @@ Rails/Delegate:
|
|
1209
1198
|
Exclude:
|
1210
1199
|
- 'lib/apipie/response_description_adapter.rb'
|
1211
1200
|
|
1212
|
-
# Offense count:
|
1201
|
+
# Offense count: 25
|
1213
1202
|
# This cop supports safe autocorrection (--autocorrect).
|
1214
1203
|
# Configuration parameters: EnforcedStyle.
|
1215
1204
|
# SupportedStyles: slashes, arguments
|
@@ -1420,7 +1409,7 @@ Style/CommentedKeyword:
|
|
1420
1409
|
- 'lib/apipie/dsl_definition.rb'
|
1421
1410
|
- 'lib/apipie/extractor/recorder.rb'
|
1422
1411
|
|
1423
|
-
# Offense count:
|
1412
|
+
# Offense count: 7
|
1424
1413
|
# This cop supports safe autocorrection (--autocorrect).
|
1425
1414
|
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
|
1426
1415
|
# SupportedStyles: assign_to_condition, assign_inside_condition
|
@@ -1455,7 +1444,7 @@ Style/EmptyCaseCondition:
|
|
1455
1444
|
|
1456
1445
|
# Offense count: 3
|
1457
1446
|
# This cop supports safe autocorrection (--autocorrect).
|
1458
|
-
# Configuration parameters: EnforcedStyle, AllowComments.
|
1447
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle, AllowComments.
|
1459
1448
|
# SupportedStyles: empty, nil, both
|
1460
1449
|
Style/EmptyElse:
|
1461
1450
|
Exclude:
|
@@ -1465,7 +1454,7 @@ Style/EmptyElse:
|
|
1465
1454
|
|
1466
1455
|
# Offense count: 27
|
1467
1456
|
# This cop supports safe autocorrection (--autocorrect).
|
1468
|
-
# Configuration parameters: EnforcedStyle.
|
1457
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
1469
1458
|
# SupportedStyles: compact, expanded
|
1470
1459
|
Style/EmptyMethod:
|
1471
1460
|
Exclude:
|
@@ -1552,7 +1541,7 @@ Style/HashExcept:
|
|
1552
1541
|
# This cop supports safe autocorrection (--autocorrect).
|
1553
1542
|
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
1554
1543
|
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
1555
|
-
# SupportedShorthandSyntax: always, never, either, consistent
|
1544
|
+
# SupportedShorthandSyntax: always, never, either, consistent, either_consistent
|
1556
1545
|
Style/HashSyntax:
|
1557
1546
|
Exclude:
|
1558
1547
|
- 'spec/dummy/config/routes.rb'
|
@@ -1687,7 +1676,7 @@ Style/Proc:
|
|
1687
1676
|
- 'spec/lib/apipie/apipies_controller_spec.rb'
|
1688
1677
|
|
1689
1678
|
# Offense count: 7
|
1690
|
-
# This cop supports
|
1679
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
1691
1680
|
# Configuration parameters: EnforcedStyle, AllowedCompactTypes.
|
1692
1681
|
# SupportedStyles: compact, exploded
|
1693
1682
|
Style/RaiseArgs:
|
@@ -1844,7 +1833,7 @@ Style/StringConcatenation:
|
|
1844
1833
|
- 'lib/apipie/application.rb'
|
1845
1834
|
- 'lib/apipie/extractor/writer.rb'
|
1846
1835
|
|
1847
|
-
# Offense count:
|
1836
|
+
# Offense count: 1233
|
1848
1837
|
# This cop supports safe autocorrection (--autocorrect).
|
1849
1838
|
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
1850
1839
|
# SupportedStyles: single_quotes, double_quotes
|
@@ -1944,7 +1933,7 @@ Style/TrailingCommaInArrayLiteral:
|
|
1944
1933
|
- 'spec/controllers/users_controller_spec.rb'
|
1945
1934
|
- 'spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb'
|
1946
1935
|
|
1947
|
-
# Offense count:
|
1936
|
+
# Offense count: 4
|
1948
1937
|
# This cop supports safe autocorrection (--autocorrect).
|
1949
1938
|
# Configuration parameters: EnforcedStyleForMultiline.
|
1950
1939
|
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
@@ -1952,7 +1941,6 @@ Style/TrailingCommaInHashLiteral:
|
|
1952
1941
|
Exclude:
|
1953
1942
|
- 'lib/apipie/generator/swagger/param_description.rb'
|
1954
1943
|
- 'lib/apipie/generator/swagger/param_description/builder.rb'
|
1955
|
-
- 'lib/apipie/response_description.rb'
|
1956
1944
|
- 'spec/controllers/users_controller_spec.rb'
|
1957
1945
|
|
1958
1946
|
# Offense count: 1
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
Changelog
|
2
2
|
===========
|
3
3
|
|
4
|
+
## [v1.4.2](https://github.com/Apipie/apipie-rails/tree/v1.4.2) (2024-07-20)
|
5
|
+
[Full Changelog](https://github.com/Apipie/apipie-rails/compare/v1.4.1...v1.4.2)
|
6
|
+
* Fix rubocop with most recent version 1.65.0 (#930) (Mathieu Jobin)
|
7
|
+
* Fix error for hash object warnings with delegated method descriptions (#938) (Murray Steele)
|
8
|
+
|
4
9
|
## [v1.4.1](https://github.com/Apipie/apipie-rails/tree/v1.4.1) (2024-07-09)
|
5
10
|
[Full Changelog](https://github.com/Apipie/apipie-rails/compare/v1.4.0...v1.4.1)
|
6
11
|
* Fix multiple rubocop offenses via rubocop_challenger. (Mathieu Jobin)
|
data/lib/apipie/application.rb
CHANGED
@@ -281,12 +281,12 @@ module Apipie
|
|
281
281
|
|
282
282
|
resources =
|
283
283
|
Apipie::Generator::Swagger::ResourceDescriptionsCollection
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
284
|
+
.new(resource_descriptions)
|
285
|
+
.filter(
|
286
|
+
resource_id: resource_id,
|
287
|
+
method_name: method_name,
|
288
|
+
version: version
|
289
|
+
)
|
290
290
|
|
291
291
|
Apipie::SwaggerGenerator.generate_from_resources(
|
292
292
|
resources,
|
@@ -17,8 +17,8 @@ class Apipie::Generator::Swagger::MethodDescription::ApiSchemaService
|
|
17
17
|
end
|
18
18
|
|
19
19
|
parameters = Apipie::Generator::Swagger::MethodDescription::ParametersService
|
20
|
-
|
21
|
-
|
20
|
+
.new(@method_description, path: path, http_method: api.normalized_http_method)
|
21
|
+
.call
|
22
22
|
|
23
23
|
paths[path.swagger_path(@method_description)] ||= {}
|
24
24
|
paths[path.swagger_path(@method_description)][api.normalized_http_method] = {
|
@@ -40,7 +40,7 @@ class Apipie::Generator::Swagger::MethodDescription::ParametersService
|
|
40
40
|
|
41
41
|
if Apipie.configuration.generator.swagger.json_input_uses_refs?
|
42
42
|
composite = composite
|
43
|
-
|
43
|
+
.referenced("#{@method_description.operation_id}_input")
|
44
44
|
end
|
45
45
|
|
46
46
|
swagger_schema_for_body = composite.to_swagger
|
@@ -80,7 +80,7 @@ class Apipie::Generator::Swagger::MethodDescription::ParametersService
|
|
80
80
|
warn_path_parameter_not_described(name, @path)
|
81
81
|
|
82
82
|
result[name.to_sym] = Apipie::Generator::Swagger::ParamDescription
|
83
|
-
|
83
|
+
.create_for_missing_param(@method_description, name)
|
84
84
|
end
|
85
85
|
|
86
86
|
result
|
@@ -89,15 +89,15 @@ class Apipie::Generator::Swagger::MethodDescription::ParametersService
|
|
89
89
|
|
90
90
|
def body_param_descriptions
|
91
91
|
@body_param_descriptions ||= all_params
|
92
|
-
|
93
|
-
|
92
|
+
.reject { |k, _| @path.param?(k) }
|
93
|
+
.values
|
94
94
|
end
|
95
95
|
|
96
96
|
def path_param_descriptions
|
97
97
|
@path_param_descriptions ||= all_params
|
98
|
-
|
99
|
-
|
100
|
-
|
98
|
+
.select { |k, _| @path.param?(k) }
|
99
|
+
.each_value { |desc| desc.required = true }
|
100
|
+
.values
|
101
101
|
end
|
102
102
|
|
103
103
|
# @return [Array]
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Apipie::Generator::Swagger::ParamDescription::Builder
|
2
2
|
# @param [Apipie::ParamDescription] param_description
|
3
3
|
# @param [TrueClass, FalseClass] in_schema
|
4
|
-
# @param [Apipie::MethodDescription] controller_method
|
4
|
+
# @param [Apipie::MethodDescription, nil] controller_method
|
5
5
|
def initialize(param_description, in_schema:, controller_method:)
|
6
6
|
@param_description = param_description
|
7
7
|
@in_schema = in_schema
|
@@ -98,8 +98,8 @@ class Apipie::Generator::Swagger::ParamDescription::Builder
|
|
98
98
|
def warn_optional_without_default_value(definition)
|
99
99
|
if !required? && !definition.key?(:default)
|
100
100
|
method_id =
|
101
|
-
if @param_description.is_a?(Apipie::ResponseDescriptionAdapter::PropDesc)
|
102
|
-
@controller_method
|
101
|
+
if @controller_method.present? && @param_description.is_a?(Apipie::ResponseDescriptionAdapter::PropDesc)
|
102
|
+
@controller_method.method_name
|
103
103
|
else
|
104
104
|
Apipie::Generator::Swagger::MethodDescription::Decorator.new(@controller_method).ruby_name
|
105
105
|
end
|
@@ -26,21 +26,21 @@ class Apipie::Generator::Swagger::ParamDescription::PathParamsComposite
|
|
26
26
|
context.add_to_prefix!(desc.name)
|
27
27
|
|
28
28
|
out = Apipie::Generator::Swagger::ParamDescription::PathParamsComposite
|
29
|
-
|
30
|
-
|
29
|
+
.new(desc.validator.params_ordered, context)
|
30
|
+
.to_swagger
|
31
31
|
|
32
32
|
@result.concat(out)
|
33
33
|
else
|
34
34
|
param_entry =
|
35
35
|
Apipie::Generator::Swagger::ParamDescription::Builder
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
.new(desc, in_schema: false, controller_method: context.controller_method)
|
37
|
+
.with_description(language: context.language)
|
38
|
+
.with_name(prefix: context.prefix)
|
39
|
+
.with_type(with_null: context.allow_null?)
|
40
|
+
.with_in(
|
41
|
+
http_method: context.http_method,
|
42
|
+
default_in_value: context.default_in_value
|
43
|
+
).to_swagger
|
44
44
|
|
45
45
|
@result << param_entry
|
46
46
|
end
|
@@ -114,7 +114,11 @@ class Apipie::Generator::Swagger::ParamDescription::Type
|
|
114
114
|
def warn_hash_without_internal_typespec
|
115
115
|
method_id =
|
116
116
|
if @param_description.is_a?(Apipie::ResponseDescriptionAdapter::PropDesc)
|
117
|
-
@controller_method.
|
117
|
+
if @controller_method.present?
|
118
|
+
@controller_method.method_name
|
119
|
+
else
|
120
|
+
Apipie::Generator::Swagger::MethodDescription::Decorator.new(nil).ruby_name
|
121
|
+
end
|
118
122
|
else
|
119
123
|
Apipie::Generator::Swagger::MethodDescription::Decorator.new(@param_description.method_description).ruby_name
|
120
124
|
end
|
@@ -41,11 +41,11 @@ class Apipie::Generator::Swagger::ResourceDescriptionComposite
|
|
41
41
|
next unless method_description.show
|
42
42
|
|
43
43
|
result = Apipie::Generator::Swagger::MethodDescription::ApiSchemaService
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
.new(
|
45
|
+
Apipie::Generator::Swagger::MethodDescription::Decorator.new(method_description),
|
46
|
+
language: @language
|
47
|
+
)
|
48
|
+
.call
|
49
49
|
|
50
50
|
results.deep_merge!(result)
|
51
51
|
end
|
@@ -16,8 +16,8 @@ module Apipie
|
|
16
16
|
def match?(path)
|
17
17
|
# Replace all null bytes
|
18
18
|
path = ::Rack::Utils.unescape(path || '')
|
19
|
-
|
20
|
-
|
19
|
+
.encode(Encoding::UTF_8, invalid: :replace, replace: '')
|
20
|
+
.gsub("\x0", '')
|
21
21
|
|
22
22
|
full_path = path.empty? ? @root : File.join(@root, path)
|
23
23
|
paths = "#{full_path}#{ext}"
|
data/lib/apipie/version.rb
CHANGED
@@ -4,7 +4,7 @@ require 'rspec/expectations'
|
|
4
4
|
require 'apipie/rspec/response_validation_helper'
|
5
5
|
require "json-schema"
|
6
6
|
|
7
|
-
RSpec.describe PetsController
|
7
|
+
RSpec.describe PetsController do
|
8
8
|
it "does not raise error when rendered output matches the described response" do
|
9
9
|
response = get :return_and_validate_expected_response, format: :json
|
10
10
|
expect(response).to match_declared_responses
|
@@ -145,6 +145,36 @@ describe Apipie::Generator::Swagger::ParamDescription::Builder do
|
|
145
145
|
/is optional but default value is not specified/
|
146
146
|
).to_stderr
|
147
147
|
end
|
148
|
+
|
149
|
+
context 'and param is a prop desc' do
|
150
|
+
let(:param_description) do
|
151
|
+
Apipie.prop(:param, 'object', param_description_options, [])
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'with a delegated controller method' do
|
155
|
+
let(:method_desc) do
|
156
|
+
Apipie::Generator::Swagger::MethodDescription::Decorator.new(
|
157
|
+
Apipie::MethodDescription.new(:show, resource_desc, dsl_data)
|
158
|
+
)
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'warns' do
|
162
|
+
expect { subject }.to output(
|
163
|
+
/is optional but default value is not specified/
|
164
|
+
).to_stderr
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
context 'with a nil controller method' do
|
169
|
+
let(:method_desc) { nil }
|
170
|
+
|
171
|
+
it 'warns' do
|
172
|
+
expect { subject }.to output(
|
173
|
+
/is optional but default value is not specified/
|
174
|
+
).to_stderr
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
148
178
|
end
|
149
179
|
end
|
150
180
|
end
|
@@ -3,7 +3,6 @@ require 'spec_helper'
|
|
3
3
|
describe Apipie::Generator::Swagger::ParamDescription::Type do
|
4
4
|
let(:validator_options) { {} }
|
5
5
|
let(:param_description_options) { {}.merge(validator_options) }
|
6
|
-
let(:with_null) { false }
|
7
6
|
let(:http_method) { :GET }
|
8
7
|
let(:path) { '/api' }
|
9
8
|
let(:validator) { String }
|
@@ -63,9 +62,11 @@ describe Apipie::Generator::Swagger::ParamDescription::Type do
|
|
63
62
|
)
|
64
63
|
end
|
65
64
|
|
65
|
+
let(:controller_method) { 'index' }
|
66
|
+
|
66
67
|
let(:type_definition) do
|
67
68
|
described_class.
|
68
|
-
new(param_description, with_null:
|
69
|
+
new(param_description, with_null: false, controller_method: controller_method).
|
69
70
|
to_hash
|
70
71
|
end
|
71
72
|
|
@@ -178,6 +179,32 @@ describe Apipie::Generator::Swagger::ParamDescription::Type do
|
|
178
179
|
it 'outputs a hash without internal typespec warning' do
|
179
180
|
expect { subject }.to output(/is a generic Hash without an internal type specification/).to_stderr
|
180
181
|
end
|
182
|
+
|
183
|
+
context 'and param is a prop desc' do
|
184
|
+
let(:param_description) do
|
185
|
+
Apipie.prop(param_description_name, 'object', {}, [])
|
186
|
+
end
|
187
|
+
|
188
|
+
context 'with a delegated controller method' do
|
189
|
+
let(:controller_method) do
|
190
|
+
Apipie::Generator::Swagger::MethodDescription::Decorator.new(
|
191
|
+
method_desc
|
192
|
+
)
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'outputs a hash without internal typespec warning' do
|
196
|
+
expect { subject }.to output(/is a generic Hash without an internal type specification/).to_stderr
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
context 'and controller method is nil' do
|
201
|
+
let(:controller_method) { nil }
|
202
|
+
|
203
|
+
it 'outputs a hash without internal typespec warning' do
|
204
|
+
expect { subject }.to output(/is a generic Hash without an internal type specification/).to_stderr
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
181
208
|
end
|
182
209
|
end
|
183
210
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -61,8 +61,11 @@ RSpec.configure do |config|
|
|
61
61
|
|
62
62
|
config.mock_with :rspec
|
63
63
|
|
64
|
-
|
65
|
-
|
64
|
+
if Rails.version >= "7.1"
|
65
|
+
config.fixture_paths = ["#{Rails.root}/spec/fixtures"]
|
66
|
+
else
|
67
|
+
config.fixture_path = "#{Rails.root}/spec/fixtures"
|
68
|
+
end
|
66
69
|
|
67
70
|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
68
71
|
# examples within a transaction, remove the following line or assign false
|