gitlab-grape-swagger 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.github/dependabot.yml +20 -0
  4. data/.github/workflows/ci.yml +45 -0
  5. data/.gitignore +44 -0
  6. data/.gitlab-ci.yml +19 -0
  7. data/.rspec +3 -0
  8. data/.rubocop.yml +136 -0
  9. data/.rubocop_todo.yml +60 -0
  10. data/.ruby-gemset +1 -0
  11. data/CHANGELOG.md +671 -0
  12. data/CONTRIBUTING.md +126 -0
  13. data/Dangerfile +3 -0
  14. data/Gemfile +45 -0
  15. data/Gemfile.lock +249 -0
  16. data/LICENSE.txt +20 -0
  17. data/README.md +1772 -0
  18. data/RELEASING.md +82 -0
  19. data/Rakefile +20 -0
  20. data/UPGRADING.md +201 -0
  21. data/example/api/endpoints.rb +131 -0
  22. data/example/api/entities.rb +18 -0
  23. data/example/config.ru +42 -0
  24. data/example/example_requests.postman_collection +146 -0
  25. data/example/splines.png +0 -0
  26. data/example/swagger-example.png +0 -0
  27. data/grape-swagger.gemspec +23 -0
  28. data/lib/grape-swagger/doc_methods/build_model_definition.rb +68 -0
  29. data/lib/grape-swagger/doc_methods/data_type.rb +110 -0
  30. data/lib/grape-swagger/doc_methods/extensions.rb +101 -0
  31. data/lib/grape-swagger/doc_methods/file_params.rb +17 -0
  32. data/lib/grape-swagger/doc_methods/format_data.rb +53 -0
  33. data/lib/grape-swagger/doc_methods/headers.rb +20 -0
  34. data/lib/grape-swagger/doc_methods/move_params.rb +209 -0
  35. data/lib/grape-swagger/doc_methods/operation_id.rb +32 -0
  36. data/lib/grape-swagger/doc_methods/optional_object.rb +30 -0
  37. data/lib/grape-swagger/doc_methods/parse_params.rb +190 -0
  38. data/lib/grape-swagger/doc_methods/path_string.rb +52 -0
  39. data/lib/grape-swagger/doc_methods/produces_consumes.rb +15 -0
  40. data/lib/grape-swagger/doc_methods/status_codes.rb +21 -0
  41. data/lib/grape-swagger/doc_methods/tag_name_description.rb +34 -0
  42. data/lib/grape-swagger/doc_methods/version.rb +20 -0
  43. data/lib/grape-swagger/doc_methods.rb +142 -0
  44. data/lib/grape-swagger/endpoint/params_parser.rb +76 -0
  45. data/lib/grape-swagger/endpoint.rb +476 -0
  46. data/lib/grape-swagger/errors.rb +17 -0
  47. data/lib/grape-swagger/instance.rb +7 -0
  48. data/lib/grape-swagger/model_parsers.rb +42 -0
  49. data/lib/grape-swagger/rake/oapi_tasks.rb +135 -0
  50. data/lib/grape-swagger/version.rb +5 -0
  51. data/lib/grape-swagger.rb +174 -0
  52. data/spec/issues/267_nested_namespaces.rb +55 -0
  53. data/spec/issues/403_versions_spec.rb +124 -0
  54. data/spec/issues/427_entity_as_string_spec.rb +39 -0
  55. data/spec/issues/430_entity_definitions_spec.rb +94 -0
  56. data/spec/issues/532_allow_custom_format_spec.rb +42 -0
  57. data/spec/issues/533_specify_status_code_spec.rb +78 -0
  58. data/spec/issues/537_enum_values_spec.rb +50 -0
  59. data/spec/issues/539_array_post_body_spec.rb +65 -0
  60. data/spec/issues/542_array_of_type_in_post_body_spec.rb +46 -0
  61. data/spec/issues/553_align_array_put_post_params_spec.rb +152 -0
  62. data/spec/issues/572_array_post_body_spec.rb +51 -0
  63. data/spec/issues/579_align_put_post_parameters_spec.rb +185 -0
  64. data/spec/issues/582_file_response_spec.rb +55 -0
  65. data/spec/issues/587_range_parameter_delimited_by_dash_spec.rb +26 -0
  66. data/spec/issues/605_root_route_documentation_spec.rb +23 -0
  67. data/spec/issues/650_params_array_spec.rb +65 -0
  68. data/spec/issues/677_consumes_produces_add_swagger_documentation_options_spec.rb +100 -0
  69. data/spec/issues/680_keep_204_error_schemas_spec.rb +55 -0
  70. data/spec/issues/721_set_default_parameter_location_based_on_consumes_spec.rb +62 -0
  71. data/spec/issues/751_deeply_nested_objects_spec.rb +190 -0
  72. data/spec/issues/776_multiple_presents_spec.rb +59 -0
  73. data/spec/issues/784_extensions_on_params_spec.rb +42 -0
  74. data/spec/issues/809_utf8_routes_spec.rb +55 -0
  75. data/spec/issues/832_array_hash_float_decimal_spec.rb +114 -0
  76. data/spec/issues/847_route_param_options_spec.rb +37 -0
  77. data/spec/issues/873_wildcard_segments_path_parameters_spec.rb +28 -0
  78. data/spec/issues/878_optional_path_segments_spec.rb +29 -0
  79. data/spec/issues/881_handle_file_params_spec.rb +38 -0
  80. data/spec/issues/883_query_array_parameter_spec.rb +46 -0
  81. data/spec/issues/884_dont_document_non_schema_examples_spec.rb +49 -0
  82. data/spec/issues/887_prevent_duplicate_operation_ids_spec.rb +35 -0
  83. data/spec/lib/data_type_spec.rb +111 -0
  84. data/spec/lib/endpoint/params_parser_spec.rb +124 -0
  85. data/spec/lib/endpoint_spec.rb +153 -0
  86. data/spec/lib/extensions_spec.rb +185 -0
  87. data/spec/lib/format_data_spec.rb +115 -0
  88. data/spec/lib/model_parsers_spec.rb +104 -0
  89. data/spec/lib/move_params_spec.rb +444 -0
  90. data/spec/lib/oapi_tasks_spec.rb +163 -0
  91. data/spec/lib/operation_id_spec.rb +55 -0
  92. data/spec/lib/optional_object_spec.rb +47 -0
  93. data/spec/lib/parse_params_spec.rb +68 -0
  94. data/spec/lib/path_string_spec.rb +101 -0
  95. data/spec/lib/produces_consumes_spec.rb +116 -0
  96. data/spec/lib/tag_name_description_spec.rb +80 -0
  97. data/spec/lib/version_spec.rb +28 -0
  98. data/spec/spec_helper.rb +39 -0
  99. data/spec/support/empty_model_parser.rb +23 -0
  100. data/spec/support/grape_version.rb +13 -0
  101. data/spec/support/mock_parser.rb +23 -0
  102. data/spec/support/model_parsers/entity_parser.rb +334 -0
  103. data/spec/support/model_parsers/mock_parser.rb +346 -0
  104. data/spec/support/model_parsers/representable_parser.rb +406 -0
  105. data/spec/support/namespace_tags.rb +93 -0
  106. data/spec/support/the_paths_definitions.rb +109 -0
  107. data/spec/swagger_v2/api_documentation_spec.rb +42 -0
  108. data/spec/swagger_v2/api_swagger_v2_additional_properties_spec.rb +83 -0
  109. data/spec/swagger_v2/api_swagger_v2_body_definitions_spec.rb +48 -0
  110. data/spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb +36 -0
  111. data/spec/swagger_v2/api_swagger_v2_detail_spec.rb +79 -0
  112. data/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +145 -0
  113. data/spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb +137 -0
  114. data/spec/swagger_v2/api_swagger_v2_global_configuration_spec.rb +56 -0
  115. data/spec/swagger_v2/api_swagger_v2_hash_and_array_spec.rb +64 -0
  116. data/spec/swagger_v2/api_swagger_v2_headers_spec.rb +58 -0
  117. data/spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb +57 -0
  118. data/spec/swagger_v2/api_swagger_v2_hide_param_spec.rb +109 -0
  119. data/spec/swagger_v2/api_swagger_v2_ignore_defaults_spec.rb +48 -0
  120. data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +153 -0
  121. data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +355 -0
  122. data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +217 -0
  123. data/spec/swagger_v2/api_swagger_v2_param_type_spec.rb +247 -0
  124. data/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb +80 -0
  125. data/spec/swagger_v2/api_swagger_v2_response_spec.rb +147 -0
  126. data/spec/swagger_v2/api_swagger_v2_response_with_examples_spec.rb +135 -0
  127. data/spec/swagger_v2/api_swagger_v2_response_with_headers_spec.rb +216 -0
  128. data/spec/swagger_v2/api_swagger_v2_response_with_models_spec.rb +53 -0
  129. data/spec/swagger_v2/api_swagger_v2_response_with_root_spec.rb +153 -0
  130. data/spec/swagger_v2/api_swagger_v2_spec.rb +245 -0
  131. data/spec/swagger_v2/api_swagger_v2_status_codes_spec.rb +93 -0
  132. data/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +90 -0
  133. data/spec/swagger_v2/boolean_params_spec.rb +38 -0
  134. data/spec/swagger_v2/default_api_spec.rb +175 -0
  135. data/spec/swagger_v2/deprecated_field_spec.rb +25 -0
  136. data/spec/swagger_v2/description_not_initialized_spec.rb +39 -0
  137. data/spec/swagger_v2/endpoint_versioned_path_spec.rb +130 -0
  138. data/spec/swagger_v2/errors_spec.rb +77 -0
  139. data/spec/swagger_v2/float_api_spec.rb +36 -0
  140. data/spec/swagger_v2/form_params_spec.rb +76 -0
  141. data/spec/swagger_v2/grape-swagger_spec.rb +17 -0
  142. data/spec/swagger_v2/guarded_endpoint_spec.rb +162 -0
  143. data/spec/swagger_v2/hide_api_spec.rb +147 -0
  144. data/spec/swagger_v2/host_spec.rb +43 -0
  145. data/spec/swagger_v2/inheritance_and_discriminator_spec.rb +57 -0
  146. data/spec/swagger_v2/mount_override_api_spec.rb +58 -0
  147. data/spec/swagger_v2/mounted_target_class_spec.rb +76 -0
  148. data/spec/swagger_v2/namespace_tags_prefix_spec.rb +122 -0
  149. data/spec/swagger_v2/namespace_tags_spec.rb +78 -0
  150. data/spec/swagger_v2/namespaced_api_spec.rb +121 -0
  151. data/spec/swagger_v2/nicknamed_api_spec.rb +25 -0
  152. data/spec/swagger_v2/operation_id_api_spec.rb +27 -0
  153. data/spec/swagger_v2/param_multi_type_spec.rb +82 -0
  154. data/spec/swagger_v2/param_type_spec.rb +95 -0
  155. data/spec/swagger_v2/param_values_spec.rb +180 -0
  156. data/spec/swagger_v2/params_array_collection_format_spec.rb +105 -0
  157. data/spec/swagger_v2/params_array_spec.rb +225 -0
  158. data/spec/swagger_v2/params_example_spec.rb +38 -0
  159. data/spec/swagger_v2/params_hash_spec.rb +77 -0
  160. data/spec/swagger_v2/params_nested_spec.rb +92 -0
  161. data/spec/swagger_v2/parent_less_namespace_spec.rb +32 -0
  162. data/spec/swagger_v2/reference_entity_spec.rb +129 -0
  163. data/spec/swagger_v2/security_requirement_spec.rb +46 -0
  164. data/spec/swagger_v2/simple_mounted_api_spec.rb +332 -0
  165. data/spec/version_spec.rb +10 -0
  166. metadata +225 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 58cdf764676d2884bb6511149d2ff6a92eb7c96185525647cce489f2f0b73d6e
4
+ data.tar.gz: c4ce33aa8867eb6b589b6bc8467c5087c2936a90b2d49012c8d5bcc9a66d03a1
5
+ SHA512:
6
+ metadata.gz: 47bdc6747fd007be8a21cf6e4033e186d2c21667a72a48116961e1504c96934c969a2046bcd7def7716b679a903d1f6138a79d96b982418800c9693a7ff1fe7e
7
+ data.tar.gz: 165813df4030daf1e47f764e9b8405715642d9d3c12f9041edb1761ba879424ec7e87314753be915948778b86ab44e01f656ece0866e08c54d6553662fcc8aa6
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,20 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "bundler" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
12
+ day: "friday"
13
+ assignees:
14
+ - "LeFnord"
15
+ - package-ecosystem: "github-actions"
16
+ directory: "/"
17
+ schedule:
18
+ interval: weekly
19
+ assignees:
20
+ - "LeFnord"
@@ -0,0 +1,45 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - '*'
7
+ pull_request:
8
+ branches:
9
+ - '*'
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ jobs:
15
+ rubocop:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v3
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: '3.1'
22
+ bundler-cache: true
23
+ - name: Run rubocop
24
+ run: bundle exec rubocop --parallel --format progress
25
+
26
+ rspec:
27
+ runs-on: ubuntu-latest
28
+ needs: ['rubocop']
29
+ strategy:
30
+ matrix:
31
+ ruby-version: ['2.7', '3.0', '3.1', 'head']
32
+ grape-version: [1.6.2, 1.5.3]
33
+ model-parser: [grape-swagger-entity, grape-swagger-representable, '']
34
+ steps:
35
+ - name: Check out branch
36
+ uses: actions/checkout@v3
37
+ - name: Set up Ruby
38
+ uses: ruby/setup-ruby@v1
39
+ with:
40
+ ruby-version: ${{ matrix.ruby-version }}
41
+ GRAPE_VERSION: ${{ matrix.grape-version }}
42
+ MODEL_PARSER: ${{ matrix.model-parser }}
43
+ bundler-cache: true
44
+ - name: Run rspec rest of the suite
45
+ run: bundle exec rspec
data/.gitignore ADDED
@@ -0,0 +1,44 @@
1
+ # yard generated
2
+ doc
3
+ .yardoc
4
+
5
+ # bundler
6
+ .bundle
7
+
8
+ #IDEA temp files
9
+ .idea
10
+
11
+ # jeweler generated
12
+ pkg
13
+
14
+ # rails stuff
15
+ log/*.log
16
+ test/dummy/db/*.sqlite3
17
+ test/dummy/log/*.log
18
+ test/dummy/tmp/
19
+ test/dummy/.sass-cache
20
+
21
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
22
+ #
23
+ # * Create a file at ~/.gitignore
24
+ # * Include files you want ignored
25
+ # * Run: git config --global core.excludesfile ~/.gitignore
26
+ #
27
+ # After doing this, these files will be ignored in all your git projects,
28
+ # saving you from having to 'pollute' every project you touch with them
29
+ #
30
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
31
+ #
32
+ # For MacOS:
33
+ #
34
+ .DS_Store
35
+ .project
36
+ example.json
37
+ swagger_spec1.2/
38
+ ToDo.md
39
+ .ruby-version
40
+ spec/params_entity_spec.rb
41
+ vendor/bundle/
42
+ spec/swagger_v2/x-dummy.rb
43
+ coverage/
44
+ .byebug_history
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,19 @@
1
+ image: ruby:latest
2
+
3
+ # Cache gems in between builds
4
+ cache:
5
+ paths:
6
+ - vendor/ruby
7
+
8
+ # This is a basic example for a gem or script which doesn't use
9
+ # services such as redis or postgres
10
+ before_script:
11
+ - ruby -v # Print out ruby version for debugging
12
+ # Uncomment next line if your rails app needs a JS runtime:
13
+ # - apt-get update -q && apt-get install nodejs -yqq
14
+ - bundle config set --local deployment true # Install dependencies into ./vendor/ruby
15
+ - bundle install -j $(nproc)
16
+
17
+ rspec:
18
+ script:
19
+ - bundle exec rspec spec
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --profile
3
+ --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,136 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ Exclude:
5
+ - vendor/**/*
6
+ - example/**/*
7
+ NewCops: enable
8
+ TargetRubyVersion: 3.1
9
+ SuggestExtensions: false
10
+
11
+ # Layout stuff
12
+ #
13
+ Layout/EmptyLinesAroundArguments:
14
+ Enabled: false
15
+
16
+ Layout/EmptyLinesAroundAttributeAccessor:
17
+ Enabled: true
18
+
19
+ Layout/FirstHashElementIndentation:
20
+ EnforcedStyle: consistent
21
+
22
+ Layout/LineLength:
23
+ Max: 120
24
+ Exclude:
25
+ - spec/**/*
26
+
27
+ Layout/SpaceAroundMethodCallOperator:
28
+ Enabled: true
29
+
30
+ # Lint stuff
31
+ #
32
+ Lint/ConstantDefinitionInBlock:
33
+ Exclude:
34
+ - spec/**/*
35
+
36
+ Lint/DeprecatedOpenSSLConstant:
37
+ Enabled: true
38
+
39
+ Lint/DuplicateElsifCondition:
40
+ Enabled: true
41
+
42
+ Lint/MixedRegexpCaptureTypes:
43
+ Enabled: true
44
+
45
+ Lint/RaiseException:
46
+ Enabled: true
47
+
48
+ Lint/StructNewOverride:
49
+ Enabled: true
50
+
51
+ # Metrics stuff
52
+ #
53
+ Metrics/BlockLength:
54
+ Exclude:
55
+ - spec/**/*
56
+
57
+ Metrics/ClassLength:
58
+ Max: 350
59
+
60
+ Metrics/CyclomaticComplexity:
61
+ Max: 17
62
+
63
+ Metrics/MethodLength:
64
+ Exclude:
65
+ - spec/**/*
66
+
67
+ # Naming stuff
68
+ #
69
+ Naming:
70
+ Enabled: false
71
+
72
+ # Style stuff
73
+ #
74
+ Style/AccessorGrouping:
75
+ Enabled: true
76
+
77
+ Style/AsciiComments:
78
+ Enabled: false
79
+
80
+ Style/ArrayCoercion:
81
+ Enabled: true
82
+
83
+ Style/BisectedAttrAccessor:
84
+ Enabled: true
85
+
86
+ Style/CaseLikeIf:
87
+ Enabled: true
88
+
89
+ Style/ExponentialNotation:
90
+ Enabled: true
91
+
92
+ Style/ExplicitBlockArgument:
93
+ Enabled: false
94
+
95
+ Style/HashAsLastArrayItem:
96
+ Enabled: true
97
+
98
+ Style/HashEachMethods:
99
+ Enabled: true
100
+
101
+ Style/HashLikeCase:
102
+ Enabled: true
103
+
104
+ Style/HashSyntax:
105
+ Enabled: false
106
+
107
+ Style/HashTransformKeys:
108
+ Enabled: true
109
+
110
+ Style/HashTransformValues:
111
+ Enabled: true
112
+
113
+ Style/OpenStructUse:
114
+ Exclude:
115
+ - spec/**/*
116
+
117
+ Style/RegexpLiteral:
118
+ Enabled: false
119
+
120
+ Style/RedundantAssignment:
121
+ Enabled: true
122
+
123
+ Style/RedundantFetchBlock:
124
+ Enabled: true
125
+
126
+ Style/RedundantFileExtensionInRequire:
127
+ Enabled: true
128
+
129
+ Style/RedundantRegexpCharacterClass:
130
+ Enabled: true
131
+
132
+ Style/RedundantRegexpEscape:
133
+ Enabled: true
134
+
135
+ Style/SlicingWithRange:
136
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,60 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2022-01-14 10:22:29 UTC using RuboCop version 1.24.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: Include.
12
+ # Include: **/*.gemspec
13
+ Gemspec/RequireMFA:
14
+ Exclude:
15
+ - 'grape-swagger.gemspec'
16
+
17
+ # Offense count: 1
18
+ # Configuration parameters: Include.
19
+ # Include: **/*.gemspec
20
+ Gemspec/RequiredRubyVersion:
21
+ Exclude:
22
+ - 'grape-swagger.gemspec'
23
+
24
+ # Offense count: 31
25
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
26
+ Metrics/AbcSize:
27
+ Max: 56
28
+
29
+ # Offense count: 30
30
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
31
+ Metrics/MethodLength:
32
+ Max: 28
33
+
34
+ # Offense count: 7
35
+ # Configuration parameters: IgnoredMethods.
36
+ Metrics/PerceivedComplexity:
37
+ Max: 16
38
+
39
+ # Offense count: 3
40
+ Style/ClassVars:
41
+ Exclude:
42
+ - 'lib/grape-swagger/doc_methods.rb'
43
+
44
+ # Offense count: 23
45
+ # Configuration parameters: AllowedConstants.
46
+ Style/Documentation:
47
+ Enabled: false
48
+
49
+ # Offense count: 43
50
+ Style/OpenStructUse:
51
+ Exclude:
52
+ - 'spec/lib/endpoint_spec.rb'
53
+ - 'spec/lib/version_spec.rb'
54
+ - 'spec/support/mock_parser.rb'
55
+ - 'spec/support/model_parsers/mock_parser.rb'
56
+ - 'spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb'
57
+ - 'spec/swagger_v2/api_swagger_v2_mounted_spec.rb'
58
+ - 'spec/swagger_v2/api_swagger_v2_spec.rb'
59
+ - 'spec/swagger_v2/errors_spec.rb'
60
+ - 'spec/swagger_v2/reference_entity_spec.rb'
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ grape-swagger