apipie-rails 0.5.19 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 444b1aeccaa322d75d64131d2539ae5ecb9ceb3ea984e02c9cfd17a2c80d1190
4
- data.tar.gz: ddbcdfaee3494a2f35f343a361c9e07b72541b5a75e5e537c0776f8b6c9669e9
3
+ metadata.gz: 29292cefe596185a3becf01f657a1c8826ea2aa5601e5549926672d1ebaf9309
4
+ data.tar.gz: 8c1419363f237e7cb8beb61940af1303bdef53a8830e0347f9afbca29d99e32f
5
5
  SHA512:
6
- metadata.gz: 18f5f97fc24bab7aa9c554cd3be305e9bf5eb5266466a79c4484fb0c7f6e4b80912d5ddb224a8ed1dd8d8002c376cd7e30a359ab4f0855d60d404352dc74acb0
7
- data.tar.gz: 1c66c6990ab997d21e727900a4a36648b76aa08357491007821c4a5f1b46b25f8e48fbb9cdeccfd26f20b1ea268c32c6698f73b040226036b0f5f72fc9447060
6
+ metadata.gz: 87f52d7d548463ec69639b85c7cb9b322b29f711fdd38800365f13bc8963a8a461f840ac8f36300e18236212b088298d90d482a0537d58b857eecbd2b479bdc5
7
+ data.tar.gz: 895cb9c91976d485ab1442f42895114e15c102cccc8d3b853ea6242de360f7756c5337faa086e4df7b5536079285ab83d259ce21b292c0da7fe766decdaddb32
@@ -0,0 +1,57 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: build
9
+
10
+ on: [push, pull_request]
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-20.04
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby:
19
+ - 2.6
20
+ - 2.7
21
+ - '3.0'
22
+ - 3.1
23
+ gemfile:
24
+ - Gemfile.rails50
25
+ - Gemfile.rails51
26
+ - Gemfile.rails52 # Min ruby 2.2.2
27
+ - Gemfile.rails60 # Min ruby 2.5.0
28
+ - Gemfile.rails61 # Min ruby 2.5.0
29
+ exclude:
30
+ - gemfile: Gemfile.rails50
31
+ ruby: 2.7
32
+ - gemfile: Gemfile.rails50
33
+ ruby: '3.0'
34
+ - gemfile: Gemfile.rails50
35
+ ruby: 3.1
36
+ - gemfile: Gemfile.rails51
37
+ ruby: 2.7
38
+ - gemfile: Gemfile.rails51
39
+ ruby: '3.0'
40
+ - gemfile: Gemfile.rails51
41
+ ruby: 3.1
42
+ - gemfile: Gemfile.rails52
43
+ ruby: 2.7
44
+ - gemfile: Gemfile.rails52
45
+ ruby: '3.0'
46
+ - gemfile: Gemfile.rails52
47
+ ruby: 3.1
48
+
49
+ env:
50
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}
51
+ steps:
52
+ - uses: actions/checkout@v2
53
+ - uses: ruby/setup-ruby@v1
54
+ with:
55
+ ruby-version: ${{ matrix.ruby }}
56
+ bundler-cache: true
57
+ - run: bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  Changelog
2
2
  ===========
3
+
4
+ ## [v0.7.0](https://github.com/Apipie/apipie-rails/tree/v0.7.0) (2022-03-30)
5
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.6.0...v0.7.0)
6
+ * ArgumentError (invalid byte sequence in UTF-8) [#746](https://github.com/Apipie/apipie-rails/pull/746) (David Milanese)
7
+ * Fix allow_blank does not work [#733](https://github.com/Apipie/apipie-rails/pull/733) (CHEN Song)
8
+ * Fix schema generation for param descriptions using the array validator in option [#732](https://github.com/Apipie/apipie-rails/pull/732) (Frank Hock)
9
+ * Remove support for Rails 4 and Ruby <= 2.5 [#747](https://github.com/Apipie/apipie-rails/pull/747) (Mathieu Jobin)
10
+
11
+ ## [v0.6.0](https://github.com/Apipie/apipie-rails/tree/v0.6.0) (2022-03-29)
12
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.5.20...v0.6.0)
13
+ * Ruby 3.0 fixes [#716](https://github.com/Apipie/apipie-rails/pull/716) (hank-spokeo)
14
+ * only depends on actionpack and activesupport [#741](https://github.com/Apipie/apipie-rails/pull/741) (Mathieu Jobin)
15
+ * language fix, fallback to default locale [#726](https://github.com/Apipie/apipie-rails/pull/726) (Alex Coomans)
16
+
17
+ ## [v0.5.20](https://github.com/Apipie/apipie-rails/tree/v0.5.20) (2022-03-16)
18
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.5.19...v0.5.20)
19
+ * Update rel-eng (Oleh Fedorenko)
20
+ * Deprecate travis, run tests on github actions [#740](https://github.com/Apipie/apipie-rails/pull/740) (Mathieu Jobin)
21
+ * Update validator.rb [#739](https://github.com/Apipie/apipie-rails/pull/739) (Dmytro Budnyk)
22
+ * Fix wrong number of arguments for recorder#process [#725](https://github.com/Apipie/apipie-rails/pull/725) (rob mathews)
23
+ * Change "an" to "a" [#723](https://github.com/Apipie/apipie-rails/pull/723) (Naokimi)
24
+
3
25
  ## [v0.5.19](https://github.com/Apipie/apipie-rails/tree/v0.5.19) (2021-07-25)
4
26
  [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.5.18...v0.5.19)
5
27
  * Add rel-eng notebook (Oleh Fedorenko)
data/README.rst CHANGED
@@ -387,20 +387,20 @@ Example:
387
387
  end
388
388
  end
389
389
 
390
- api :POST, "/users", "Create an user"
390
+ api :POST, "/users", "Create a user"
391
391
  param_group :user
392
392
  def create
393
393
  # ...
394
394
  end
395
395
 
396
- api :PUT, "/users/:id", "Update an user"
396
+ api :PUT, "/users/:id", "Update a user"
397
397
  param_group :user
398
398
  def update
399
399
  # ...
400
400
  end
401
401
 
402
402
  # v2/users_controller.rb
403
- api :POST, "/users", "Create an user"
403
+ api :POST, "/users", "Create a user"
404
404
  param_group :user, V1::UsersController
405
405
  def create
406
406
  # ...
@@ -434,7 +434,7 @@ Example
434
434
  end
435
435
  end
436
436
 
437
- api :POST, "/users", "Create an user"
437
+ api :POST, "/users", "Create a user"
438
438
  param_group :user
439
439
  def create
440
440
  # ...
@@ -446,7 +446,7 @@ Example
446
446
  # ...
447
447
  end
448
448
 
449
- api :PUT, "/users/:id", "Update an user"
449
+ api :PUT, "/users/:id", "Update a user"
450
450
  param_group :user
451
451
  def update
452
452
  # ...
data/apipie-rails.gemspec CHANGED
@@ -10,13 +10,14 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "http://github.com/Apipie/apipie-rails"
11
11
  s.summary = %q{Rails REST API documentation tool}
12
12
  s.description = %q{Rails REST API documentation tool}
13
- s.required_ruby_version = '>= 2.0.0'
13
+ s.required_ruby_version = '>= 2.6.0'
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
17
  s.require_paths = ["lib"]
18
18
 
19
- s.add_dependency "rails", ">= 4.1"
19
+ s.add_dependency "actionpack", ">= 5.0"
20
+ s.add_dependency "activesupport", ">= 5.0"
20
21
  s.add_development_dependency "rspec-rails", "~> 3.0"
21
22
  s.add_development_dependency "sqlite3"
22
23
  s.add_development_dependency "minitest"
@@ -100,7 +100,7 @@ module Apipie
100
100
  [:resource, :method, :version].each do |par|
101
101
  if params[par]
102
102
  splitted = params[par].split('.')
103
- if splitted.length > 1 && Apipie.configuration.languages.include?(splitted.last)
103
+ if splitted.length > 1 && (Apipie.configuration.languages.include?(splitted.last) || Apipie.configuration.default_locale == splitted.last)
104
104
  lang = splitted.last
105
105
  params[par].sub!(".#{lang}", '')
106
106
  end
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'actionpack', '~> 5.0.0'
6
+ gem 'activesupport', '~> 5.0.0'
7
+ gem 'mime-types', '~> 2.99.3'
8
+ gem 'rails-controller-testing'
9
+
10
+ gem 'test_engine', path: '../spec/dummy/components/test_engine', group: :test
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'actionpack', '~> 5.1.0'
6
+ gem 'activesupport', '~> 5.1.0'
7
+ gem 'mime-types', '~> 2.99.3'
8
+ gem 'rails-controller-testing'
9
+
10
+ gem 'test_engine', path: '../spec/dummy/components/test_engine', group: :test
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'actionpack', '~> 5.2.6'
6
+ gem 'activesupport', '~> 5.2.6'
7
+ gem 'mime-types', '~> 2.99.3'
8
+ gem 'rails-controller-testing'
9
+
10
+ gem 'test_engine', path: '../spec/dummy/components/test_engine', group: :test
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'actionpack', '~> 6.0.4'
6
+ gem 'activesupport', '~> 6.0.4'
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
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'actionpack', '~> 6.1.5'
6
+ gem 'activesupport', '~> 6.1.5'
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
@@ -150,8 +150,8 @@ module Apipie
150
150
  end
151
151
 
152
152
  module FunctionalTestRecording
153
- def process(*args) # action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
154
- ret = super(*args)
153
+ def process(*, **) # action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
154
+ ret = super
155
155
  if Apipie.configuration.record
156
156
  Apipie::Extractor.call_recorder.analyze_functional_test(self)
157
157
  Apipie::Extractor.call_finished
@@ -160,6 +160,7 @@ module Apipie
160
160
  ensure
161
161
  Apipie::Extractor.clean_call_recorder
162
162
  end
163
+ ruby2_keywords :process if respond_to?(:ruby2_keywords, true)
163
164
  end
164
165
  end
165
166
  end
@@ -117,7 +117,7 @@ module Apipie
117
117
  return true if @allow_nil && value.nil?
118
118
  return true if @allow_blank && value.blank?
119
119
  value = normalized_value(value)
120
- if (!@allow_nil && value.nil?) || !@validator.valid?(value)
120
+ if (!@allow_nil && value.nil?) || (!@allow_blank && value.blank?) || !@validator.valid?(value)
121
121
  error = @validator.error
122
122
  error = ParamError.new(error) unless error.is_a? StandardError
123
123
  raise error
@@ -9,7 +9,9 @@ module Apipie
9
9
 
10
10
  def match?(path)
11
11
  # Replace all null bytes
12
- path = ::Rack::Utils.unescape(path || '').gsub(/\x0/, '')
12
+ path = ::Rack::Utils.unescape(path || '')
13
+ .encode(Encoding::UTF_8, invalid: :replace, replace: '')
14
+ .gsub(/\x0/, '')
13
15
 
14
16
  full_path = path.empty? ? @root : File.join(@root, path)
15
17
  paths = "#{full_path}#{ext}"
@@ -476,6 +476,9 @@ module Apipie
476
476
 
477
477
  if swagger_def[:type] == "array"
478
478
  swagger_def[:items] = {type: "string"}
479
+ enum = param_desc.options.fetch(:in, [])
480
+
481
+ swagger_def[:items][:enum] = enum if enum.any?
479
482
  end
480
483
 
481
484
  if swagger_def[:type] == "enum"
@@ -504,7 +507,8 @@ module Apipie
504
507
  end
505
508
 
506
509
  if !in_schema
507
- swagger_def[:in] = param_desc.options.fetch(:in, @default_value_for_param_in)
510
+ # the "name" and "in" keys can only be set on root parameters (non-nested)
511
+ swagger_def[:in] = @default_value_for_param_in if name.present?
508
512
  swagger_def[:required] = param_desc.required if param_desc.required
509
513
  end
510
514
 
@@ -3,7 +3,7 @@ module Apipie
3
3
 
4
4
  module Validator
5
5
 
6
- # to create new validator, inherit from Apipie::Validator::Base
6
+ # to create new validator, inherit from Apipie::Validator::BaseValidator
7
7
  # and implement class method build and instance method validate
8
8
  class BaseValidator
9
9
 
@@ -1,3 +1,3 @@
1
1
  module Apipie
2
- VERSION = "0.5.19"
2
+ VERSION = "0.7.0"
3
3
  end
data/lib/apipie-rails.rb CHANGED
@@ -23,7 +23,3 @@ require "apipie/railtie"
23
23
  require 'apipie/extractor'
24
24
  require "apipie/version"
25
25
  require "apipie/swagger_generator"
26
-
27
- if Rails.version.start_with?("3.0")
28
- warn 'Warning: apipie-rails is not going to support Rails 3.0 anymore in future versions'
29
- end
@@ -10,7 +10,8 @@
10
10
  "- push access to https://github.com/Apipie/apipie-rails\n",
11
11
  "- push access to rubygems.org for apipie-rails\n",
12
12
  "- sudo yum install python-slugify asciidoc\n",
13
- "- ensure neither the `git push` or `gem push` don't require interractive auth. If you can't use api key or ssh key to auth skip these steps and run them form the shell manually \n",
13
+ "- ensure neither the `git push` or `gem push` don't require interractive auth. If you can't use api key or ssh key to auth skip these steps and run them form the shell manually\n",
14
+ "- ensure all checks have passed on the branch you're about to release\n",
14
15
  "\n",
15
16
  "### Release process\n",
16
17
  "- Follow the steps with `<Shift>+<Enter>` or `<Ctrl>+<Enter>,<Down>`\n",
@@ -19,6 +20,15 @@
19
20
  "### Release settings"
20
21
  ]
21
22
  },
23
+ {
24
+ "cell_type": "code",
25
+ "execution_count": null,
26
+ "metadata": {},
27
+ "outputs": [],
28
+ "source": [
29
+ "%autosave 0"
30
+ ]
31
+ },
22
32
  {
23
33
  "cell_type": "code",
24
34
  "execution_count": null,
@@ -41,10 +51,14 @@
41
51
  "metadata": {},
42
52
  "outputs": [],
43
53
  "source": [
44
- "NEW_VERSION = '0.5.19'\n",
45
- "LAST_VERSION = '0.5.18'\n",
54
+ "NEW_VERSION = '0.5.20'\n",
55
+ "LAST_VERSION = '0.5.19'\n",
46
56
  "GIT_REMOTE_UPSTREAM = 'origin'\n",
47
- "WORK_BRANCH = 'master'\n"
57
+ "STABLE_RELEASE = False\n",
58
+ "WORK_BRANCH = 'stable' if STABLE_RELEASE else 'master'\n",
59
+ "# Array of strings, e.g. [\"21cbsc214g3\", \"21casc214g3\"]\n",
60
+ "CHERRY_PICKS = []\n",
61
+ "GEMFILE='Gemfile.rails61'"
48
62
  ]
49
63
  },
50
64
  {
@@ -85,7 +99,25 @@
85
99
  "cell_type": "markdown",
86
100
  "metadata": {},
87
101
  "source": [
88
- "### Run tests localy"
102
+ "### Cherry picks for stable release"
103
+ ]
104
+ },
105
+ {
106
+ "cell_type": "code",
107
+ "execution_count": null,
108
+ "metadata": {},
109
+ "outputs": [],
110
+ "source": [
111
+ "if STABLE_RELEASE:\n",
112
+ " for cp in CHERRY_PICKS:\n",
113
+ " ! git cherry-pick -x {cp}"
114
+ ]
115
+ },
116
+ {
117
+ "cell_type": "markdown",
118
+ "metadata": {},
119
+ "source": [
120
+ "### Run tests localy if your setup allows, otherwise ensure the HEAD is green"
89
121
  ]
90
122
  },
91
123
  {
@@ -94,7 +126,7 @@
94
126
  "metadata": {},
95
127
  "outputs": [],
96
128
  "source": [
97
- "! bundle update"
129
+ "! BUNDLE_GEMFILE=gemfiles/{GEMFILE} bundle update"
98
130
  ]
99
131
  },
100
132
  {
@@ -105,7 +137,7 @@
105
137
  },
106
138
  "outputs": [],
107
139
  "source": [
108
- "! bundle exec rake"
140
+ "! BUNDLE_GEMFILE=gemfiles/{GEMFILE} bundle exec rspec"
109
141
  ]
110
142
  },
111
143
  {
@@ -249,7 +281,7 @@
249
281
  "metadata": {},
250
282
  "outputs": [],
251
283
  "source": [
252
- "! git tag v{NEW_VERSION}"
284
+ "! git tag {NEW_VERSION}"
253
285
  ]
254
286
  },
255
287
  {
@@ -265,7 +297,7 @@
265
297
  "metadata": {},
266
298
  "outputs": [],
267
299
  "source": [
268
- "! rake build"
300
+ "! BUNDLE_GEMFILE=gemfiles/{GEMFILE} bundle exec rake build"
269
301
  ]
270
302
  },
271
303
  {
@@ -47,6 +47,31 @@ describe Apipie::ApipiesController do
47
47
 
48
48
  assert_response :not_found
49
49
  end
50
+
51
+ it "succeeds on method details with a supported language" do
52
+ allow(Apipie.configuration).to receive(:languages).and_return(%w[en es])
53
+
54
+ get :index, :params => { :version => "2.0", :resource => "architectures", :method => "index.es" }
55
+
56
+ assert_response :success
57
+ end
58
+
59
+ it "succeeds on method details with the default language" do
60
+ allow(Apipie.configuration).to receive(:default_locale).and_return("en")
61
+ allow(Apipie.configuration).to receive(:languages).and_return([])
62
+
63
+ get :index, :params => { :version => "2.0", :resource => "architectures", :method => "index.en" }
64
+
65
+ assert_response :success
66
+ end
67
+
68
+ it "returns not_found on a method with an unsupported language" do
69
+ allow(Apipie.configuration).to receive(:languages).and_return(%w[en es])
70
+
71
+ get :index, :params => { :version => "2.0", :resource => "architectures", :method => "index.jp" }
72
+
73
+ assert_response :not_found
74
+ end
50
75
  end
51
76
 
52
77
  describe "reload_controllers" do
@@ -274,6 +274,12 @@ class UsersController < ApplicationController
274
274
  render :plain => 'nothing to see here'
275
275
  end
276
276
 
277
+ api :GET, '/users/in_departments', 'show users from specific departments'
278
+ param :departments, Array, in: ["finance", "operations", "sales", "marketing", "HR"], default_value: ['sales']
279
+ def get_in_departments
280
+ render :plain => 'nothing to see here'
281
+ end
282
+
277
283
  api :GET, '/users/desc_from_file', 'desc from file'
278
284
  document 'users/desc_from_file.md'
279
285
  def desc_from_file
@@ -1,10 +1,7 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
- require "active_model/railtie"
4
- require "active_record/railtie"
5
3
  require "action_controller/railtie"
6
4
  require "action_view/railtie"
7
- require "action_mailer/railtie"
8
5
 
9
6
  Bundler.require
10
7
  require "apipie-rails"
@@ -13,9 +13,6 @@ Dummy::Application.configure do
13
13
  config.consider_all_requests_local = true
14
14
  config.action_controller.perform_caching = false
15
15
 
16
- # Don't care if the mailer can't send
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
16
  # Print deprecation notices to the Rails logger
20
17
  config.active_support.deprecation = :log
21
18
 
@@ -34,9 +34,6 @@ Dummy::Application.configure do
34
34
  # Enable serving of images, stylesheets, and javascripts from an asset server
35
35
  # config.action_controller.asset_host = "http://assets.example.com"
36
36
 
37
- # Disable delivery errors, bad email addresses will be ignored
38
- # config.action_mailer.raise_delivery_errors = false
39
-
40
37
  # Enable threaded mode
41
38
  # config.threadsafe!
42
39
 
@@ -20,11 +20,6 @@ Dummy::Application.configure do
20
20
  # Disable request forgery protection in test environment
21
21
  config.action_controller.allow_forgery_protection = false
22
22
 
23
- # Tell Action Mailer not to deliver emails to the real world.
24
- # The :test delivery method accumulates sent emails in the
25
- # ActionMailer::Base.deliveries array.
26
- config.action_mailer.delivery_method = :test
27
-
28
23
  # Use SQL instead of Active Record's schema dumper when creating the test database.
29
24
  # This is necessary if your schema can't be completely dumped by the schema dumper,
30
25
  # like if you have constraints or database-specific column types
@@ -14,5 +14,12 @@ describe Apipie::FileHandler do
14
14
  it { expect(file_handler.match? path).to be_falsy }
15
15
  it { expect { file_handler.match? path }.to_not raise_error }
16
16
  end
17
+
18
+ context 'when the path contans an invalid byte sequence in UTF-8' do
19
+ let(:path) { "%B6" }
20
+
21
+ it { expect(file_handler.match? path).to be_falsy }
22
+ it { expect { file_handler.match? path }.to_not raise_error }
23
+ end
17
24
  end
18
25
  end
@@ -51,6 +51,17 @@ describe 'rake tasks' do
51
51
  expect(param[field]).to eq(value)
52
52
  end
53
53
 
54
+ def expect_array_param_def(http_method, path, param_name, value)
55
+ params = apidoc_swagger["paths"][path][http_method]["parameters"]
56
+ param = params.select { |p| p if p["name"] == param_name }[0]
57
+
58
+ expect(param['type']).to eq('array')
59
+ expect(param['items']).to eq(
60
+ 'type' => 'string',
61
+ 'enum' => value
62
+ )
63
+ end
64
+
54
65
  def expect_tags_def(http_method, path, value)
55
66
  params = apidoc_swagger["paths"][path][http_method]["tags"]
56
67
  expect(params).to eq(value)
@@ -119,6 +130,10 @@ describe 'rake tasks' do
119
130
  expect_param_def("get", "/users/by_department", "department", "enum",
120
131
  ["finance", "operations", "sales", "marketing", "HR"])
121
132
 
133
+ expect_param_def("get", "/users/in_departments", "departments", "in", "query")
134
+ expect_array_param_def("get", "/users/in_departments", "departments",
135
+ ["finance", "operations", "sales", "marketing", "HR"])
136
+
122
137
  expect_tags_def("get", "/twitter_example/{id}/followers", %w[twitter_example following index search])
123
138
 
124
139
  end
@@ -10,78 +10,78 @@ RSpec.describe PetsController, :type => :controller do
10
10
  end
11
11
 
12
12
  it "does not raise error when rendered output matches the described response" do
13
- response = get :return_and_validate_expected_response, {format: :json}
13
+ response = get :return_and_validate_expected_response, format: :json
14
14
  expect(response).to match_declared_responses
15
15
  end
16
16
 
17
17
  it "does not raise error when rendered output (array) matches the described response" do
18
- response = get :return_and_validate_expected_array_response, {format: :json}
18
+ response = get :return_and_validate_expected_array_response, format: :json
19
19
  expect(response).to match_declared_responses
20
20
  end
21
21
 
22
22
  it "does not raises error when rendered output includes null in the response" do
23
- response = get :return_and_validate_expected_response_with_null, {format: :json}
23
+ response = get :return_and_validate_expected_response_with_null, format: :json
24
24
  expect(response).to match_declared_responses
25
25
  end
26
26
 
27
27
  it "does not raise error when rendered output includes null (instead of an object) in the response" do
28
- response = get :return_and_validate_expected_response_with_null_object, {format: :json}
28
+ response = get :return_and_validate_expected_response_with_null_object, format: :json
29
29
  expect(response).to match_declared_responses
30
30
  end
31
31
 
32
32
  it "raises error when a response field has the wrong type" do
33
- response = get :return_and_validate_type_mismatch, {format: :json}
33
+ response = get :return_and_validate_type_mismatch, format: :json
34
34
  expect(response).not_to match_declared_responses
35
35
  end
36
36
 
37
37
  it "raises error when a response has a missing field" do
38
- response = get :return_and_validate_missing_field, {format: :json}
38
+ response = get :return_and_validate_missing_field, format: :json
39
39
  expect(response).not_to match_declared_responses
40
40
  end
41
41
 
42
42
  it "raises error when a response has an extra property and 'swagger_allow_additional_properties_in_response' is false" do
43
- response = get :return_and_validate_extra_property, {format: :json}
43
+ response = get :return_and_validate_extra_property, format: :json
44
44
  expect(response).not_to match_declared_responses
45
45
  end
46
46
 
47
47
  it "raises error when a response has is array instead of object" do
48
48
  # note: this action returns HTTP 201, not HTTP 200!
49
- response = get :return_and_validate_unexpected_array_response, {format: :json}
49
+ response = get :return_and_validate_unexpected_array_response, format: :json
50
50
  expect(response).not_to match_declared_responses
51
51
  end
52
52
 
53
53
  it "does not raise error when a response has an extra property and 'swagger_allow_additional_properties_in_response' is true" do
54
54
  Apipie.configuration.swagger_allow_additional_properties_in_response = true
55
- response = get :return_and_validate_extra_property, {format: :json}
55
+ response = get :return_and_validate_extra_property, format: :json
56
56
  expect(response).to match_declared_responses
57
57
  end
58
58
 
59
59
  it "does not raise error when a response has an extra field and 'additional_properties' is specified in the response" do
60
60
  Apipie.configuration.swagger_allow_additional_properties_in_response = false
61
- response = get :return_and_validate_allowed_extra_property, {format: :json}
61
+ response = get :return_and_validate_allowed_extra_property, format: :json
62
62
  expect(response).to match_declared_responses
63
63
  end
64
64
 
65
65
  it "raises error when a response sub-object has an extra field and 'additional_properties' is not specified on it, but specified on the top level of the response" do
66
66
  Apipie.configuration.swagger_allow_additional_properties_in_response = false
67
- response = get :sub_object_invalid_extra_property, {format: :json}
67
+ response = get :sub_object_invalid_extra_property, format: :json
68
68
  expect(response).not_to match_declared_responses
69
69
  end
70
70
 
71
- it "does not rais error when a response sub-object has an extra field and 'additional_properties' is specified on it" do
71
+ it "does not raise error when a response sub-object has an extra field and 'additional_properties' is specified on it" do
72
72
  Apipie.configuration.swagger_allow_additional_properties_in_response = false
73
- response = get :sub_object_allowed_extra_property, {format: :json}
73
+ response = get :sub_object_allowed_extra_property, format: :json
74
74
  expect(response).to match_declared_responses
75
75
  end
76
76
 
77
77
  describe "auto validation" do
78
78
  auto_validate_rendered_views
79
79
  it "raises exception when a response field has the wrong type and auto validation is turned on" do
80
- expect { get :return_and_validate_type_mismatch, {format: :json} }.to raise_error(Apipie::ResponseDoesNotMatchSwaggerSchema)
80
+ expect { get :return_and_validate_type_mismatch, format: :json }.to raise_error(Apipie::ResponseDoesNotMatchSwaggerSchema)
81
81
  end
82
82
 
83
83
  it "does not raise an exception when calling an undocumented method" do
84
- expect { get :undocumented_method, {format: :json} }.not_to raise_error
84
+ expect { get :undocumented_method, format: :json }.not_to raise_error
85
85
  end
86
86
 
87
87
  end
@@ -89,12 +89,12 @@ RSpec.describe PetsController, :type => :controller do
89
89
 
90
90
  describe "with array field" do
91
91
  it "no error for valid response" do
92
- response = get :returns_response_with_valid_array, {format: :json}
92
+ response = get :returns_response_with_valid_array, format: :json
93
93
  expect(response).to match_declared_responses
94
94
  end
95
95
 
96
96
  it "error if type of element in the array is wrong" do
97
- response = get :returns_response_with_invalid_array, {format: :json}
97
+ response = get :returns_response_with_invalid_array, format: :json
98
98
  expect(response).not_to match_declared_responses
99
99
  end
100
100
  end
data/spec/spec_helper.rb CHANGED
@@ -13,7 +13,13 @@ require 'test_engine'
13
13
  module Rails4Compatibility
14
14
  module Testing
15
15
  def process(*args)
16
- compatible_request(*args) { |*new_args| super(*new_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
17
23
  end
18
24
 
19
25
  def compatible_request(method, action, hash = {})
@@ -0,0 +1,15 @@
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
+
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.5.19
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pokorny
@@ -9,22 +9,36 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-07-25 00:00:00.000000000 Z
12
+ date: 2022-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rails
15
+ name: actionpack
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '4.1'
20
+ version: '5.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '4.1'
27
+ version: '5.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: activesupport
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '5.0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '5.0'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: rspec-rails
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -145,18 +159,12 @@ executables: []
145
159
  extensions: []
146
160
  extra_rdoc_files: []
147
161
  files:
162
+ - ".github/workflows/build.yml"
148
163
  - ".gitignore"
149
164
  - ".rspec"
150
- - ".travis.yml"
151
165
  - APACHE-LICENSE-2.0
152
166
  - CHANGELOG.md
153
167
  - Gemfile
154
- - Gemfile.rails41
155
- - Gemfile.rails42
156
- - Gemfile.rails50
157
- - Gemfile.rails51
158
- - Gemfile.rails60
159
- - Gemfile.rails61
160
168
  - MIT-LICENSE
161
169
  - NOTICE
162
170
  - PROPOSAL_FOR_RESPONSE_DESCRIPTIONS.md
@@ -203,6 +211,11 @@ files:
203
211
  - config/locales/tr.yml
204
212
  - config/locales/zh-CN.yml
205
213
  - config/locales/zh-TW.yml
214
+ - gemfiles/Gemfile.rails50
215
+ - gemfiles/Gemfile.rails51
216
+ - gemfiles/Gemfile.rails52
217
+ - gemfiles/Gemfile.rails60
218
+ - gemfiles/Gemfile.rails61
206
219
  - images/screenshot-1.png
207
220
  - images/screenshot-2.png
208
221
  - lib/apipie-rails.rb
@@ -324,6 +337,7 @@ files:
324
337
  - spec/lib/validator_spec.rb
325
338
  - spec/lib/validators/array_validator_spec.rb
326
339
  - spec/spec_helper.rb
340
+ - spec/support/rails-42-ruby-26.rb
327
341
  - spec/support/rake.rb
328
342
  homepage: http://github.com/Apipie/apipie-rails
329
343
  licenses: []
@@ -336,96 +350,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
336
350
  requirements:
337
351
  - - ">="
338
352
  - !ruby/object:Gem::Version
339
- version: 2.0.0
353
+ version: 2.6.0
340
354
  required_rubygems_version: !ruby/object:Gem::Requirement
341
355
  requirements:
342
356
  - - ">="
343
357
  - !ruby/object:Gem::Version
344
358
  version: '0'
345
359
  requirements: []
346
- rubygems_version: 3.1.2
360
+ rubygems_version: 3.0.9
347
361
  signing_key:
348
362
  specification_version: 4
349
363
  summary: Rails REST API documentation tool
350
- test_files:
351
- - spec/controllers/api/v1/architectures_controller_spec.rb
352
- - spec/controllers/api/v2/architectures_controller_spec.rb
353
- - spec/controllers/api/v2/nested/resources_controller_spec.rb
354
- - spec/controllers/apipies_controller_spec.rb
355
- - spec/controllers/concerns_controller_spec.rb
356
- - spec/controllers/extended_controller_spec.rb
357
- - spec/controllers/memes_controller_spec.rb
358
- - spec/controllers/users_controller_spec.rb
359
- - spec/dummy/Rakefile
360
- - spec/dummy/app/controllers/api/base_controller.rb
361
- - spec/dummy/app/controllers/api/v1/architectures_controller.rb
362
- - spec/dummy/app/controllers/api/v1/base_controller.rb
363
- - spec/dummy/app/controllers/api/v2/architectures_controller.rb
364
- - spec/dummy/app/controllers/api/v2/base_controller.rb
365
- - spec/dummy/app/controllers/api/v2/nested/architectures_controller.rb
366
- - spec/dummy/app/controllers/api/v2/nested/resources_controller.rb
367
- - spec/dummy/app/controllers/application_controller.rb
368
- - spec/dummy/app/controllers/concerns/extending_concern.rb
369
- - spec/dummy/app/controllers/concerns/sample_controller.rb
370
- - spec/dummy/app/controllers/concerns_controller.rb
371
- - spec/dummy/app/controllers/extended_controller.rb
372
- - spec/dummy/app/controllers/files_controller.rb
373
- - spec/dummy/app/controllers/overridden_concerns_controller.rb
374
- - spec/dummy/app/controllers/pets_controller.rb
375
- - spec/dummy/app/controllers/pets_using_auto_views_controller.rb
376
- - spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb
377
- - spec/dummy/app/controllers/tagged_cats_controller.rb
378
- - spec/dummy/app/controllers/tagged_dogs_controller.rb
379
- - spec/dummy/app/controllers/twitter_example_controller.rb
380
- - spec/dummy/app/controllers/users_controller.rb
381
- - spec/dummy/app/views/layouts/application.html.erb
382
- - spec/dummy/components/test_engine/Gemfile
383
- - spec/dummy/components/test_engine/app/controllers/test_engine/application_controller.rb
384
- - spec/dummy/components/test_engine/app/controllers/test_engine/memes_controller.rb
385
- - spec/dummy/components/test_engine/config/routes.rb
386
- - spec/dummy/components/test_engine/db/.gitkeep
387
- - spec/dummy/components/test_engine/lib/test_engine.rb
388
- - spec/dummy/components/test_engine/test_engine.gemspec
389
- - spec/dummy/config.ru
390
- - spec/dummy/config/application.rb
391
- - spec/dummy/config/boot.rb
392
- - spec/dummy/config/database.yml
393
- - spec/dummy/config/environment.rb
394
- - spec/dummy/config/environments/development.rb
395
- - spec/dummy/config/environments/production.rb
396
- - spec/dummy/config/environments/test.rb
397
- - spec/dummy/config/initializers/apipie.rb
398
- - spec/dummy/config/initializers/backtrace_silencers.rb
399
- - spec/dummy/config/initializers/inflections.rb
400
- - spec/dummy/config/initializers/mime_types.rb
401
- - spec/dummy/config/initializers/secret_token.rb
402
- - spec/dummy/config/initializers/session_store.rb
403
- - spec/dummy/config/locales/en.yml
404
- - spec/dummy/config/routes.rb
405
- - spec/dummy/db/.gitkeep
406
- - spec/dummy/doc/apipie_examples.json
407
- - spec/dummy/doc/users/desc_from_file.md
408
- - spec/dummy/public/404.html
409
- - spec/dummy/public/422.html
410
- - spec/dummy/public/500.html
411
- - spec/dummy/public/favicon.ico
412
- - spec/dummy/public/stylesheets/.gitkeep
413
- - spec/dummy/script/rails
414
- - spec/lib/application_spec.rb
415
- - spec/lib/extractor/extractor_spec.rb
416
- - spec/lib/extractor/middleware_spec.rb
417
- - spec/lib/extractor/writer_spec.rb
418
- - spec/lib/file_handler_spec.rb
419
- - spec/lib/method_description_spec.rb
420
- - spec/lib/param_description_spec.rb
421
- - spec/lib/param_group_spec.rb
422
- - spec/lib/rake_spec.rb
423
- - spec/lib/resource_description_spec.rb
424
- - spec/lib/swagger/openapi_2_0_schema.json
425
- - spec/lib/swagger/rake_swagger_spec.rb
426
- - spec/lib/swagger/response_validation_spec.rb
427
- - spec/lib/swagger/swagger_dsl_spec.rb
428
- - spec/lib/validator_spec.rb
429
- - spec/lib/validators/array_validator_spec.rb
430
- - spec/spec_helper.rb
431
- - spec/support/rake.rb
364
+ test_files: []
data/.travis.yml DELETED
@@ -1,41 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- before_install: >-
4
- if ruby -v | grep 'ruby 2.2'; then
5
- gem install bundler -v '~> 1.17'
6
- fi
7
- rvm:
8
- - 2.2.10
9
- - 2.3.8
10
- - 2.4.5
11
- - 2.5.3
12
- - 2.6.5
13
- - 2.7.0
14
- gemfile:
15
- - Gemfile.rails42
16
- - Gemfile.rails51 # Min ruby 2.2.2
17
- - Gemfile.rails60 # Min ruby 2.5.0
18
- - Gemfile.rails61 # Min ruby 2.5.0
19
-
20
- matrix:
21
- exclude:
22
- - rvm: 2.5.3
23
- gemfile: Gemfile.rails42
24
- - rvm: 2.6.5
25
- gemfile: Gemfile.rails42
26
- - rvm: 2.7.0
27
- gemfile: Gemfile.rails42
28
- - rvm: 2.7.0
29
- gemfile: Gemfile.rails51
30
- - rvm: 2.2.10
31
- gemfile: Gemfile.rails60
32
- - rvm: 2.3.8
33
- gemfile: Gemfile.rails60
34
- - rvm: 2.4.5
35
- gemfile: Gemfile.rails60
36
- - rvm: 2.2.10
37
- gemfile: Gemfile.rails61
38
- - rvm: 2.3.8
39
- gemfile: Gemfile.rails61
40
- - rvm: 2.4.5
41
- gemfile: Gemfile.rails61
data/Gemfile.rails41 DELETED
@@ -1,7 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- gem 'rails', '~> 4.1.0'
6
- gem 'mime-types', '~> 2.99.3'
7
- gem 'test_engine', path: 'spec/dummy/components/test_engine', group: :test
data/Gemfile.rails42 DELETED
@@ -1,14 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- gem 'rails', '~> 4.2.5'
6
- gem 'mime-types', '~> 2.99.3'
7
- gem 'sqlite3', '~> 1.3.6'
8
-
9
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.1.0')
10
- gem 'nokogiri', '~> 1.6.8'
11
- gem 'rdoc', '~> 4.2.2'
12
- end
13
-
14
- gem 'test_engine', path: 'spec/dummy/components/test_engine', group: :test
data/Gemfile.rails50 DELETED
@@ -1,9 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- gem 'rails', '~> 5.0.0'
6
- gem 'mime-types', '~> 2.99.3'
7
- gem 'rails-controller-testing'
8
-
9
- gem 'test_engine', path: 'spec/dummy/components/test_engine', group: :test
data/Gemfile.rails51 DELETED
@@ -1,9 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- gem 'rails', '~> 5.1.0.rc1'
6
- gem 'mime-types', '~> 2.99.3'
7
- gem 'rails-controller-testing'
8
-
9
- gem 'test_engine', path: 'spec/dummy/components/test_engine', group: :test
data/Gemfile.rails60 DELETED
@@ -1,10 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- gem 'rails', '~> 6.0.2'
6
- gem 'mime-types', '~> 2.99.3'
7
- gem 'rails-controller-testing'
8
- gem 'rspec-rails', '4.0.0.beta3'
9
-
10
- gem 'test_engine', path: 'spec/dummy/components/test_engine', group: :test
data/Gemfile.rails61 DELETED
@@ -1,10 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- gem 'rails', '~> 6.1.1'
6
- gem 'mime-types', '~> 2.99.3'
7
- gem 'rails-controller-testing'
8
- gem 'rspec-rails', '~> 4.0.2'
9
-
10
- gem 'test_engine', path: 'spec/dummy/components/test_engine', group: :test