apipie-rails 0.7.2 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7a94176378d53856507d3df6c324e69b2637430e6d627726d344fc427e619a7
4
- data.tar.gz: 5f00ebcf9cf5fb2940e86681f2fbdb685ed215bf3708ebcc41ab0f34a0f2bab1
3
+ metadata.gz: dc951bacc1fe43a5e6959b51f722e5a63d37eac5b3b264603d64e93f039d7e34
4
+ data.tar.gz: 57ab01c41ef9a23b25ccc40f8f4686aace3c2a4601c35bc1c4492b918561e96a
5
5
  SHA512:
6
- metadata.gz: fd4340d9646496246e06454941c93ebae9039d59c0449e5b9683f01aa18cd02414ea0233f0345e09f4b4107f8daeb84387ace0af32b5e2d82cea0f6cbd57a53b
7
- data.tar.gz: 6abd0665093f3e7c9fd2d9bcf965bf85b2b4bbff937c52b317c4601898e6a71683686cdcc690f7983826db612e9f5910b55b18a011f1755f1c9b884f20681fdf
6
+ metadata.gz: be9da39bd717e0f74bfa1b603fcab4db662bc77139b9062c4f1397f7094c5d464c52462f4580017d8e16ffc13961383b0de8ec9d8841aa9606642ec9b633ceba
7
+ data.tar.gz: 3c72fb02a1bbed1103c98f3c9a906ee54e657a4bfd65d673c614c03525d43e66d4e8da0e06899c29c814f2a848612f2a342fc984a45b6492121f2fe4e2b27399
@@ -26,6 +26,7 @@ jobs:
26
26
  - Gemfile.rails52 # Min ruby 2.2.2
27
27
  - Gemfile.rails60 # Min ruby 2.5.0
28
28
  - Gemfile.rails61 # Min ruby 2.5.0
29
+ - Gemfile.rails70 # Min ruby 2.7.0
29
30
  exclude:
30
31
  - gemfile: Gemfile.rails50
31
32
  ruby: 2.7
@@ -45,6 +46,8 @@ jobs:
45
46
  ruby: '3.0'
46
47
  - gemfile: Gemfile.rails52
47
48
  ruby: 3.1
49
+ - gemfile: Gemfile.rails70
50
+ ruby: 2.6
48
51
 
49
52
  env:
50
53
  BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  .bundle/
2
2
  log/*.log
3
3
  pkg/
4
+ coverage
4
5
  spec/dummy/db/*.sqlite3
5
6
  spec/dummy/log/*.log
6
7
  spec/dummy/tmp/
data/CHANGELOG.md CHANGED
@@ -1,6 +1,31 @@
1
1
  Changelog
2
2
  ===========
3
3
 
4
+ Also deleted the `Gemfile` that was now a broken symlink.
5
+ please use `export BUNDLE_GEMFILE='gemfiles/Gemfile.rails61'; bundle exec rspec` to run the test suite
6
+
7
+ ## [v0.8.2](https://github.com/Apipie/apipie-rails/tree/v0.8.2) (2022-09-03)
8
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.8.1...v0.8.2)
9
+ * Allow custom validators to opt out of allow_blank behavior [#762](https://github.com/Apipie/apipie-rails/pull/762). (Stephen Hanson)
10
+ * Enforce test coverage, set current 89% as minimum [#764](https://github.com/Apipie/apipie-rails/pull/764). (Mathieu Jobin)
11
+ * Add contributing instructions to readme [#763](https://github.com/Apipie/apipie-rails/pull/763). (Stephen Hanson)
12
+ * Fix readme formatting [#765](https://github.com/Apipie/apipie-rails/pull/765). (Stephen Hanson)
13
+ * Adds expected_type to IntegerValidator example [#769](https://github.com/Apipie/apipie-rails/pull/769). (Jeremy Liberman)
14
+ * Update readme with error handling example [#768](https://github.com/Apipie/apipie-rails/pull/768). (Jesse Eisenberg)
15
+ * 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)
16
+
17
+ ## [v0.8.1](https://github.com/Apipie/apipie-rails/tree/v0.8.1) (2022-05-26)
18
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.8.0...v0.8.1)
19
+ * 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)
20
+
21
+ ## [v0.8.0](https://github.com/Apipie/apipie-rails/tree/v0.8.0) (2022-05-24)
22
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.7.2...v0.8.0)
23
+ * Add support for scheme definition in Swagger docs. [#710](https://github.com/Apipie/apipie-rails/pull/710) (Dan Leyden)
24
+ * Add support for Rails 7 [#760](https://github.com/Apipie/apipie-rails/pull/760) (Mathieu Jobin)
25
+ * Clean up code base, removing all trace of unsupported Rails 4.x [#752](https://github.com/Apipie/apipie-rails/pull/752) (Mathieu Jobin)
26
+ * fix: Controller resource set before version [#744](https://github.com/Apipie/apipie-rails/pull/744) (LuukvH)
27
+ * 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)
28
+
4
29
  ## [v0.7.2](https://github.com/Apipie/apipie-rails/tree/v0.7.2) (2022-04-19)
5
30
  [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.7.1...v0.7.2)
6
31
  * 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)
data/README.rst CHANGED
@@ -1156,6 +1156,21 @@ is raised and can be rescued and processed. It contains a description
1156
1156
  of the parameter value expectations. Validations can be turned off
1157
1157
  in the configuration file.
1158
1158
 
1159
+ Here is an example of how to rescue and process a +ParamMissing+ or
1160
+ +ParamInvalid+ error from within the ApplicationController.
1161
+
1162
+ .. code:: ruby
1163
+
1164
+ class ApplicationController < ActionController::Base
1165
+
1166
+ # ParamError is superclass of ParamMissing, ParamInvalid
1167
+ rescue_from Apipie::ParamError do |e|
1168
+ render text: e.message, status: :unprocessable_entity
1169
+ end
1170
+
1171
+ # ...
1172
+ end
1173
+
1159
1174
  Parameter validation normally happens after before_actions, just before
1160
1175
  your controller method is invoked. If you prefer to control when parameter
1161
1176
  validation occurs, set the configuration parameter ``validate`` to ``:explicitly``.
@@ -1368,6 +1383,10 @@ So we create apipie_validators.rb initializer with this content:
1368
1383
  def description
1369
1384
  "Must be #{@type}."
1370
1385
  end
1386
+
1387
+ def expected_type
1388
+ 'numeric'
1389
+ end
1371
1390
  end
1372
1391
 
1373
1392
  Parameters of the build method:
@@ -1385,6 +1404,16 @@ options
1385
1404
  block
1386
1405
  Block converted into Proc, use it as you desire. In this example nil.
1387
1406
 
1407
+ If your validator includes valid values that respond true to `.blank?`, you
1408
+ should also define:
1409
+
1410
+ .. code:: ruby
1411
+
1412
+ def ignore_allow_blank?
1413
+ true
1414
+ end
1415
+
1416
+ so that the validation does not fail for valid values.
1388
1417
 
1389
1418
  ============
1390
1419
  Versioning
@@ -1660,6 +1689,11 @@ There are several configuration parameters that determine the structure of the g
1660
1689
 
1661
1690
  If ``true``: the ``additional-properties: false`` field will not be included in response object descriptions
1662
1691
 
1692
+ ``config.swagger_schemes``
1693
+ An array of transport schemes that the API supports.
1694
+ This can include any combination of ``http``, ``https``, ``ws`` and ``wss``.
1695
+ By default to encourage good security practices, ``['https']`` is specified.
1696
+
1663
1697
 
1664
1698
  ``config:swagger_security_definitions``
1665
1699
  If the API requires authentication, you can specify details of the authentication mechanisms supported as a (Hash) value here.
@@ -1867,6 +1901,20 @@ provided it uses Apipie as a backend.
1867
1901
 
1868
1902
  And if you write one on your own, don't hesitate to share it with us!
1869
1903
 
1904
+ ====================
1905
+ Contributing
1906
+ ====================
1907
+
1908
+ Since this gem does not have a Gemfile, you need to specify it in your shell with:
1909
+
1910
+ .. code:: shell
1911
+ BUNDLE_GEMFILE='gemfiles/Gemfile.rails61'
1912
+
1913
+ Then, you can install dependencies and run the test suite:
1914
+
1915
+ .. code:: shell
1916
+ > bundle install
1917
+ > bundle exec rspec
1870
1918
 
1871
1919
  ====================
1872
1920
  Disqus Integration
data/apipie-rails.gemspec CHANGED
@@ -25,5 +25,6 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency "RedCloth"
26
26
  s.add_development_dependency "rake"
27
27
  s.add_development_dependency "rdoc"
28
+ s.add_development_dependency "simplecov"
28
29
  s.add_development_dependency "json-schema", "~> 2.8"
29
30
  end
@@ -34,7 +34,7 @@ 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
 
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'actionpack', '~> 7.0.2'
6
+ gem 'activesupport', '~> 7.0.2'
7
+ gem 'mime-types', '~> 3.0'
8
+ gem 'rails-controller-testing'
9
+ gem 'rspec-rails', '~> 5.0'
10
+
11
+ # net-smtp not included by default in Ruby 3.1
12
+ # Will be fixed by https://github.com/mikel/mail/pull/1439
13
+ if Gem.ruby_version >= Gem::Version.new("3.1.0")
14
+ gem 'net-smtp', require: false
15
+ end
16
+
17
+ gem 'test_engine', path: '../spec/dummy/components/test_engine', group: :test
@@ -40,8 +40,10 @@ module Apipie
40
40
  flatten_routes = []
41
41
 
42
42
  route_set.routes.each do |route|
43
- # This is a hack to workaround a bug in apipie with Rails 4.2.5.1 or newer. See https://github.com/Apipie/apipie-rails/issues/415
44
- route_app = Rails::VERSION::STRING.to_f >= 4.2 ? route.app.app : route.app
43
+ # route is_a ActionDispatch::Journey::Route
44
+ # route.app is_a ActionDispatch::Routing::Mapper::Constraints
45
+ # route.app.app is_a TestEngine::Engine
46
+ route_app = route.app.app
45
47
  if route_app.respond_to?(:routes) && route_app.routes.is_a?(ActionDispatch::Routing::RouteSet)
46
48
  # recursively go though the mounted engines
47
49
  flatten_routes.concat(rails_routes(route_app.routes, File.join(base_url, route.path.spec.to_s)))
@@ -456,10 +458,10 @@ module Apipie
456
458
  # as this would break loading of the controllers.
457
459
  def rails_mark_classes_for_reload
458
460
  unless Rails.application.config.cache_classes
459
- Rails::VERSION::MAJOR == 4 ? ActionDispatch::Reloader.cleanup! : Rails.application.reloader.reload!
461
+ Rails.application.reloader.reload!
460
462
  init_env
461
463
  reload_examples
462
- Rails::VERSION::MAJOR == 4 ? ActionDispatch::Reloader.prepare! : Rails.application.reloader.prepare!
464
+ Rails.application.reloader.prepare!
463
465
  end
464
466
  end
465
467
 
@@ -12,7 +12,7 @@ module Apipie
12
12
  :swagger_include_warning_tags, :swagger_content_type_input, :swagger_json_input_uses_refs,
13
13
  :swagger_suppress_warnings, :swagger_api_host, :swagger_generate_x_computed_id_field,
14
14
  :swagger_allow_additional_properties_in_response, :swagger_responses_use_refs,
15
- :swagger_security_definitions, :swagger_global_security
15
+ :swagger_schemes, :swagger_security_definitions, :swagger_global_security
16
16
 
17
17
  alias_method :validate?, :validate
18
18
  alias_method :required_by_default?, :required_by_default
@@ -184,6 +184,7 @@ module Apipie
184
184
  @swagger_generate_x_computed_id_field = false
185
185
  @swagger_allow_additional_properties_in_response = false
186
186
  @swagger_responses_use_refs = true
187
+ @swagger_schemes = [:https]
187
188
  @swagger_security_definitions = {}
188
189
  @swagger_global_security = []
189
190
  end
@@ -149,10 +149,10 @@ module Apipie
149
149
 
150
150
  dsl_data = ResourceDescriptionDsl.eval_dsl(self, &block)
151
151
  versions = dsl_data[:api_versions]
152
+ Apipie.set_controller_versions(self, versions)
152
153
  @apipie_resource_descriptions = versions.map do |version|
153
154
  Apipie.define_resource_description(self, version, dsl_data)
154
155
  end
155
- Apipie.set_controller_versions(self, versions)
156
156
  end
157
157
  end
158
158
 
@@ -17,14 +17,8 @@ class Apipie::Railtie
17
17
  end
18
18
  app.middleware.use ::Apipie::Extractor::Recorder::Middleware
19
19
 
20
- if Gem::Version.new(Rails.version) < Gem::Version.new('5.0.0')
21
- ActionController::TestCase::Behavior.instance_eval do
22
- prepend Apipie::Extractor::Recorder::FunctionalTestRecording
23
- end
24
- else
25
- ActionController::TestCase.send(:prepend, Apipie::Extractor::Recorder::FunctionalTestRecording)
26
- ActionController::TestCase::Behavior.send(:prepend, Apipie::Extractor::Recorder::FunctionalTestRecording)
27
- end
20
+ ActionController::TestCase.send(:prepend, Apipie::Extractor::Recorder::FunctionalTestRecording)
21
+ ActionController::TestCase::Behavior.send(:prepend, Apipie::Extractor::Recorder::FunctionalTestRecording)
28
22
  end
29
23
  end
30
24
 
@@ -125,7 +125,7 @@ module Apipie
125
125
  end
126
126
 
127
127
  def blank_forbidden?
128
- !Apipie.configuration.ignore_allow_blank_false && !allow_blank && !validator.is_a?(Validator::BooleanValidator)
128
+ !Apipie.configuration.ignore_allow_blank_false && !allow_blank && !validator.ignore_allow_blank?
129
129
  end
130
130
 
131
131
  def process_value(value)
@@ -161,8 +161,8 @@ ActionController::TestCase::Behavior.instance_eval do
161
161
  # instrument the 'process' method in ActionController::TestCase to enable response validation
162
162
  module Apipie::ResponseValidationHelpers
163
163
  @is_response_validation_on = false
164
- def process(*args)
165
- result = super(*args)
164
+ def process(*, **)
165
+ result = super
166
166
  validate_response if @is_response_validation_on
167
167
 
168
168
  result
@@ -73,6 +73,7 @@ module Apipie
73
73
  consumes: [],
74
74
  paths: {},
75
75
  definitions: {},
76
+ schemes: Apipie.configuration.swagger_schemes,
76
77
  tags: [],
77
78
  securityDefinitions: Apipie.configuration.swagger_security_definitions,
78
79
  security: Apipie.configuration.swagger_global_security
@@ -477,9 +478,16 @@ module Apipie
477
478
  end
478
479
 
479
480
  if swagger_def[:type] == "array"
480
- swagger_def[:items] = {type: "string"}
481
- enum = param_desc.options.fetch(:in, [])
481
+ array_of_validator_opts = param_desc.validator.param_description.options
482
+ items_type = array_of_validator_opts[:of].to_s || array_of_validator_opts[:array_of].to_s
483
+ if items_type == "Hash"
484
+ ref_name = "#{swagger_op_id_for_path(param_desc.method_description.apis.first.http_method, param_desc.method_description.apis.first.path)}_param_#{param_desc.name}"
485
+ swagger_def[:items] = {"$ref" => gen_referenced_block_from_params_array(ref_name, param_desc.validator.param_description.validator.params_ordered, allow_nulls)}
486
+ else
487
+ swagger_def[:items] = {type: "string"}
488
+ end
482
489
 
490
+ enum = param_desc.options.fetch(:in, [])
483
491
  swagger_def[:items][:enum] = enum if enum.any?
484
492
  end
485
493
 
@@ -80,6 +80,10 @@ module Apipie
80
80
  'string'
81
81
  end
82
82
 
83
+ def ignore_allow_blank?
84
+ false
85
+ end
86
+
83
87
  def merge_with(other_validator)
84
88
  return self if self == other_validator
85
89
  raise NotImplementedError, "Don't know how to merge #{self.inspect} with #{other_validator.inspect}"
@@ -333,6 +337,7 @@ module Apipie
333
337
  @params_ordered ||= _apipie_dsl_data[:params].map do |args|
334
338
  options = args.find { |arg| arg.is_a? Hash }
335
339
  options[:parent] = self.param_description
340
+ options[:param_group] = @param_group
336
341
  Apipie::ParamDescription.from_dsl_data(param_description.method_description, args)
337
342
  end
338
343
  end
@@ -477,6 +482,10 @@ module Apipie
477
482
  string = %w(true false 1 0).map { |value| format_description_value(value) }.join(', ')
478
483
  "Must be one of: #{string}."
479
484
  end
485
+
486
+ def ignore_allow_blank?
487
+ true
488
+ end
480
489
  end
481
490
 
482
491
  class NestedValidator < BaseValidator
@@ -1,3 +1,3 @@
1
1
  module Apipie
2
- VERSION = "0.7.2"
2
+ VERSION = "0.8.2"
3
3
  end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe IncludedParamGroupController do
5
+
6
+ let(:dsl_data) { ActionController::Base.send(:_apipie_dsl_data_init) }
7
+
8
+ it "should not error when there is a param_group that is deeply nested in response description" do
9
+ subject = Apipie.get_resource_description(IncludedParamGroupController, Apipie.configuration.default_version)
10
+ expect(subject._methods.keys).to include(:show)
11
+ end
12
+
13
+ end
@@ -3,6 +3,6 @@ class ConcernsController < ApplicationController
3
3
  resource_description { resource_id 'concern_resources' }
4
4
 
5
5
  apipie_concern_subst(:concern => 'user', :custom_subst => 'custom', 'string_subst' => 'string')
6
- include ::Concerns::SampleController
6
+ include SampleController
7
7
 
8
8
  end
@@ -1,4 +1,3 @@
1
- module Concerns
2
1
  module ExtendingConcern
3
2
  extend Apipie::DSL::Concern
4
3
 
@@ -9,4 +8,3 @@ module Concerns
9
8
  meta metadata: 'data'
10
9
  end
11
10
  end
12
- end
@@ -0,0 +1,19 @@
1
+ class IncludedParamGroupController < ApplicationController
2
+ include RandomParamGroup
3
+
4
+ api :GET, '/included-param-group'
5
+ returns code:200 do
6
+ property :top_level, Array, of: Hash do
7
+ param_group :random_param_group
8
+ end
9
+ property :nested, Hash do
10
+ property :random_array, Array, of: Hash do
11
+ param_group :random_param_group
12
+ end
13
+ end
14
+ end
15
+ def show
16
+ end
17
+
18
+ end
19
+
@@ -3,7 +3,7 @@ class OverriddenConcernsController < ApplicationController
3
3
  resource_description { resource_id 'overridden_concern_resources' }
4
4
 
5
5
  apipie_concern_subst(:concern => 'user')
6
- include ::Concerns::SampleController
6
+ include SampleController
7
7
 
8
8
  def_param_group :concern do
9
9
  param :concern, String
@@ -11,7 +11,7 @@ class OverriddenConcernsController < ApplicationController
11
11
 
12
12
  api :PUT, '/:resource_id/:id'
13
13
  param :custom_parameter, String, "New parameter added by the overriding method"
14
- param_group :concern, ::Concerns::SampleController
14
+ param_group :concern, SampleController
15
15
  def update
16
16
  super
17
17
  end
@@ -1,4 +1,3 @@
1
- module Concerns
2
1
  module SampleController
3
2
  extend Apipie::DSL::Concern
4
3
 
@@ -38,4 +37,3 @@ module Concerns
38
37
  render :plain => "OK #{params.inspect}"
39
38
  end
40
39
  end
41
- end
@@ -0,0 +1,8 @@
1
+ module RandomParamGroup
2
+ def self.included(klazz)
3
+ klazz.def_param_group :random_param_group do
4
+ property :id, Integer
5
+ property :name, String
6
+ end
7
+ end
8
+ end
@@ -41,7 +41,7 @@ module Dummy
41
41
  config.filter_parameters += [:password]
42
42
 
43
43
  config.to_prepare do
44
- ExtendedController.send(:include, Concerns::ExtendingConcern)
44
+ ExtendedController.send(:include, ExtendingConcern)
45
45
  end
46
46
  end
47
47
  end
@@ -157,11 +157,29 @@ describe Apipie::ParamDescription do
157
157
  expect { Apipie::ParamDescription.new(method_desc, :param, :boolean).validate(false) }.to_not raise_error
158
158
  end
159
159
 
160
+ it "should still not throw an exception when passed false with explicit allow_blank: false" do
161
+ expect { Apipie::ParamDescription.new(method_desc, :param, :boolean, allow_blank: false).validate(false) }.to_not raise_error
162
+ end
163
+
160
164
  it "should throw an exception when passed an empty value" do
161
165
  expect { Apipie::ParamDescription.new(method_desc, :param, :boolean).validate('') }.to raise_error(Apipie::ParamInvalid)
162
166
  end
163
167
  end
164
168
 
169
+ context "when the parameter is a custom type with ignore_allow_blank? returning true" do
170
+ it "should not throw an exception when passed a blank but valid value" do
171
+ expect { Apipie::ParamDescription.new(method_desc, :param, :custom_bool).validate(false) }.to_not raise_error
172
+ end
173
+
174
+ it "should still not throw an exception when passed false with explicit allow_blank: false" do
175
+ expect { Apipie::ParamDescription.new(method_desc, :param, :custom_bool, allow_blank: false).validate(false) }.to_not raise_error
176
+ end
177
+
178
+ it "should throw an exception when passed an invalid but blank value" do
179
+ expect { Apipie::ParamDescription.new(method_desc, :param, :custom_bool).validate("") }.to raise_error(Apipie::ParamInvalid)
180
+ end
181
+ end
182
+
165
183
  context 'when the parameter is a string' do
166
184
  context 'when allow_blank is specified as true' do
167
185
  it "should throw an exception when passed an empty value" do
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
3
 
4
+ require 'simplecov'
5
+ SimpleCov.minimum_coverage 89
6
+ SimpleCov.start
7
+
4
8
  ENV["RAILS_ENV"] ||= 'test'
5
9
  APIPIE_ROOT = File.expand_path('../..', __FILE__)
6
10
  require File.expand_path("../dummy/config/environment", __FILE__)
@@ -10,37 +14,6 @@ require 'rspec/rails'
10
14
  require 'apipie-rails'
11
15
  require 'test_engine'
12
16
 
13
- module Rails4Compatibility
14
- module Testing
15
- def process(*args)
16
- compatible_request(*args) do |*new_args|
17
- if Gem.ruby_version < Gem::Version.new('3.0.0')
18
- super(*new_args)
19
- else
20
- super(new_args[0], **new_args[1])
21
- end
22
- end
23
- end
24
-
25
- def compatible_request(method, action, hash = {})
26
- if hash.is_a?(Hash)
27
- if Gem::Version.new(Rails.version) < Gem::Version.new('5.0.0')
28
- hash = hash.dup
29
- hash.merge!(hash.delete(:params) || {})
30
- elsif hash.key?(:params)
31
- hash = { :params => hash }
32
- end
33
- end
34
- if hash.empty?
35
- yield method, action
36
- else
37
- yield method, action, hash
38
- end
39
- end
40
- end
41
- end
42
-
43
-
44
17
  #
45
18
  # Matcher to validate the properties (name, type and options) of a single field in the
46
19
  # internal representation of a swagger schema
@@ -114,4 +87,3 @@ RSpec.configure do |config|
114
87
  end
115
88
 
116
89
  require 'action_controller/test_case.rb'
117
- ActionController::TestCase::Behavior.send(:prepend, Rails4Compatibility::Testing)
@@ -0,0 +1,17 @@
1
+ class CustomBoolValidator < Apipie::Validator::BaseValidator
2
+ def validate(value)
3
+ value.in?([true, false])
4
+ end
5
+
6
+ def self.build(param_description, argument, options, block)
7
+ new(param_description) if argument == :custom_bool
8
+ end
9
+
10
+ def description
11
+ "Must be a boolean."
12
+ end
13
+
14
+ def ignore_allow_blank?
15
+ true
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apipie-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pokorny
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-04-19 00:00:00.000000000 Z
12
+ date: 2022-09-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -137,6 +137,20 @@ dependencies:
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: simplecov
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
140
154
  - !ruby/object:Gem::Dependency
141
155
  name: json-schema
142
156
  requirement: !ruby/object:Gem::Requirement
@@ -216,6 +230,7 @@ files:
216
230
  - gemfiles/Gemfile.rails52
217
231
  - gemfiles/Gemfile.rails60
218
232
  - gemfiles/Gemfile.rails61
233
+ - gemfiles/Gemfile.rails70
219
234
  - images/screenshot-1.png
220
235
  - images/screenshot-2.png
221
236
  - lib/apipie-rails.rb
@@ -263,6 +278,7 @@ files:
263
278
  - spec/controllers/apipies_controller_spec.rb
264
279
  - spec/controllers/concerns_controller_spec.rb
265
280
  - spec/controllers/extended_controller_spec.rb
281
+ - spec/controllers/included_param_group_controller_spec.rb
266
282
  - spec/controllers/memes_controller_spec.rb
267
283
  - spec/controllers/users_controller_spec.rb
268
284
  - spec/dummy/Rakefile
@@ -274,19 +290,21 @@ files:
274
290
  - spec/dummy/app/controllers/api/v2/nested/architectures_controller.rb
275
291
  - spec/dummy/app/controllers/api/v2/nested/resources_controller.rb
276
292
  - spec/dummy/app/controllers/application_controller.rb
277
- - spec/dummy/app/controllers/concerns/extending_concern.rb
278
- - spec/dummy/app/controllers/concerns/sample_controller.rb
279
293
  - spec/dummy/app/controllers/concerns_controller.rb
280
294
  - spec/dummy/app/controllers/extended_controller.rb
295
+ - spec/dummy/app/controllers/extending_concern.rb
281
296
  - spec/dummy/app/controllers/files_controller.rb
297
+ - spec/dummy/app/controllers/included_param_group_controller.rb
282
298
  - spec/dummy/app/controllers/overridden_concerns_controller.rb
283
299
  - spec/dummy/app/controllers/pets_controller.rb
284
300
  - spec/dummy/app/controllers/pets_using_auto_views_controller.rb
285
301
  - spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb
302
+ - spec/dummy/app/controllers/sample_controller.rb
286
303
  - spec/dummy/app/controllers/tagged_cats_controller.rb
287
304
  - spec/dummy/app/controllers/tagged_dogs_controller.rb
288
305
  - spec/dummy/app/controllers/twitter_example_controller.rb
289
306
  - spec/dummy/app/controllers/users_controller.rb
307
+ - spec/dummy/app/helpers/random_param_group.rb
290
308
  - spec/dummy/app/views/layouts/application.html.erb
291
309
  - spec/dummy/components/test_engine/Gemfile
292
310
  - spec/dummy/components/test_engine/app/controllers/test_engine/application_controller.rb
@@ -337,7 +355,7 @@ files:
337
355
  - spec/lib/validator_spec.rb
338
356
  - spec/lib/validators/array_validator_spec.rb
339
357
  - spec/spec_helper.rb
340
- - spec/support/rails-42-ruby-26.rb
358
+ - spec/support/custom_bool_validator.rb
341
359
  - spec/support/rake.rb
342
360
  homepage: http://github.com/Apipie/apipie-rails
343
361
  licenses: []
@@ -357,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
357
375
  - !ruby/object:Gem::Version
358
376
  version: '0'
359
377
  requirements: []
360
- rubygems_version: 3.1.6
378
+ rubygems_version: 3.3.5
361
379
  signing_key:
362
380
  specification_version: 4
363
381
  summary: Rails REST API documentation tool
@@ -1,15 +0,0 @@
1
- if RUBY_VERSION >= '2.6.0'
2
- if Rails.version < '5'
3
- # rubocop:disable Style/CommentAnnotation
4
- class ActionController::TestResponse < ActionDispatch::TestResponse
5
- def recycle!
6
- # hack to avoid MonitorMixin double-initialize error:
7
- @mon_mutex_owner_object_id = nil
8
- @mon_mutex = nil
9
- initialize
10
- end
11
- end
12
- # rubocop:enable Style/CommentAnnotation
13
- end
14
- end
15
-