apipie-rails 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +7 -0
- data/.rubocop_todo.yml +4 -14
- data/CHANGELOG.md +6 -1
- data/README.rst +2 -2
- data/app/controllers/apipie/apipies_controller.rb +1 -1
- data/lib/apipie/application.rb +4 -4
- data/lib/apipie/dsl_definition.rb +1 -1
- data/lib/apipie/extractor/writer.rb +2 -2
- data/lib/apipie/method_description.rb +2 -2
- data/lib/apipie/resource_description.rb +1 -1
- data/lib/apipie/version.rb +1 -1
- data/lib/tasks/apipie.rake +2 -2
- data/spec/controllers/apipies_controller_spec.rb +2 -2
- data/spec/controllers/users_controller_spec.rb +1 -1
- data/spec/dummy/app/controllers/users_controller.rb +1 -1
- data/spec/dummy/config/initializers/apipie.rb +2 -2
- data/spec/lib/extractor/writer_spec.rb +1 -1
- data/spec/lib/param_description_spec.rb +4 -4
- data/spec/lib/rake_spec.rb +1 -3
- data/spec/lib/validator_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68c72bdd4204b9dcb285d9f663c4c64dce315af16f9463d9e8ee9b8f28bfc14b
|
4
|
+
data.tar.gz: 25c735365fb4b4733d9eab9b7f5b9439b1d8200113b550ab56c94c9d33253c10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbbfcb973af34864e3e6793d483e32adb3ff8d7e37ee676ec1e485bd4cd094e62c774b41ebe86219cd6e8ffdc2930579125298a918b3d0fc5e48bfaa4fc2260b
|
7
|
+
data.tar.gz: 132c1d5652fc466c42f8f888ce5b9015531ba7d54d1c4c0227d843ed5b3ae0761a0acb365a0ef08135bf10ef8312b30b6fe099f6fe075eec23fd54c079ad9f92
|
data/.github/workflows/build.yml
CHANGED
@@ -20,6 +20,7 @@ jobs:
|
|
20
20
|
- 2.7
|
21
21
|
- '3.0'
|
22
22
|
- 3.1
|
23
|
+
- 3.2
|
23
24
|
gemfile:
|
24
25
|
- Gemfile.rails50
|
25
26
|
- Gemfile.rails51
|
@@ -34,18 +35,24 @@ jobs:
|
|
34
35
|
ruby: '3.0'
|
35
36
|
- gemfile: Gemfile.rails50
|
36
37
|
ruby: 3.1
|
38
|
+
- gemfile: Gemfile.rails50
|
39
|
+
ruby: 3.2
|
37
40
|
- gemfile: Gemfile.rails51
|
38
41
|
ruby: 2.7
|
39
42
|
- gemfile: Gemfile.rails51
|
40
43
|
ruby: '3.0'
|
41
44
|
- gemfile: Gemfile.rails51
|
42
45
|
ruby: 3.1
|
46
|
+
- gemfile: Gemfile.rails51
|
47
|
+
ruby: 3.2
|
43
48
|
- gemfile: Gemfile.rails52
|
44
49
|
ruby: 2.7
|
45
50
|
- gemfile: Gemfile.rails52
|
46
51
|
ruby: '3.0'
|
47
52
|
- gemfile: Gemfile.rails52
|
48
53
|
ruby: 3.1
|
54
|
+
- gemfile: Gemfile.rails52
|
55
|
+
ruby: 3.2
|
49
56
|
- gemfile: Gemfile.rails70
|
50
57
|
ruby: 2.6
|
51
58
|
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2022-09-
|
3
|
+
# on 2022-09-30 23:40:43 UTC using RuboCop version 1.36.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
|
@@ -401,7 +401,7 @@ Layout/SpaceAroundOperators:
|
|
401
401
|
- 'spec/lib/swagger/rake_swagger_spec.rb'
|
402
402
|
- 'spec/lib/swagger/swagger_dsl_spec.rb'
|
403
403
|
|
404
|
-
# Offense count:
|
404
|
+
# Offense count: 38
|
405
405
|
# This cop supports safe autocorrection (--autocorrect).
|
406
406
|
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
407
407
|
# SupportedStyles: space, no_space
|
@@ -438,7 +438,7 @@ Layout/SpaceInsideArrayLiteralBrackets:
|
|
438
438
|
- 'lib/apipie/extractor/writer.rb'
|
439
439
|
- 'spec/controllers/users_controller_spec.rb'
|
440
440
|
|
441
|
-
# Offense count:
|
441
|
+
# Offense count: 91
|
442
442
|
# This cop supports safe autocorrection (--autocorrect).
|
443
443
|
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
444
444
|
# SupportedStyles: space, no_space
|
@@ -1610,10 +1610,9 @@ Style/MissingRespondToMissing:
|
|
1610
1610
|
Exclude:
|
1611
1611
|
- 'lib/apipie/apipie_module.rb'
|
1612
1612
|
|
1613
|
-
# Offense count:
|
1613
|
+
# Offense count: 1
|
1614
1614
|
Style/MultilineBlockChain:
|
1615
1615
|
Exclude:
|
1616
|
-
- 'lib/apipie/method_description.rb'
|
1617
1616
|
- 'lib/apipie/param_description.rb'
|
1618
1617
|
|
1619
1618
|
# Offense count: 2
|
@@ -1931,15 +1930,6 @@ Style/StringLiterals:
|
|
1931
1930
|
Style/SymbolArray:
|
1932
1931
|
EnforcedStyle: brackets
|
1933
1932
|
|
1934
|
-
# Offense count: 4
|
1935
|
-
# This cop supports unsafe autocorrection (--autocorrect-all).
|
1936
|
-
# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, IgnoredMethods, AllowComments.
|
1937
|
-
# AllowedMethods: respond_to, define_method
|
1938
|
-
Style/SymbolProc:
|
1939
|
-
Exclude:
|
1940
|
-
- 'lib/apipie/method_description.rb'
|
1941
|
-
- 'lib/tasks/apipie.rake'
|
1942
|
-
|
1943
1933
|
# Offense count: 2
|
1944
1934
|
# This cop supports safe autocorrection (--autocorrect).
|
1945
1935
|
# Configuration parameters: EnforcedStyleForMultiline.
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,12 @@
|
|
4
4
|
Also deleted the `Gemfile` that was now a broken symlink.
|
5
5
|
please use `export BUNDLE_GEMFILE='gemfiles/Gemfile.rails61'; bundle exec rspec` to run the test suite
|
6
6
|
|
7
|
-
|
7
|
+
## [v0.9.1](https://github.com/Apipie/apipie-rails/tree/v0.9.1) (2023-01-16)
|
8
|
+
[Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.9.0...v0.9.1)
|
9
|
+
* [Refactor] Create test cache files under a not version controlled directory [#809](https://github.com/Apipie/apipie-rails/pull/809) (Panos Dalitsouris)
|
10
|
+
* [Ruby] Support for Ruby 3.2 [#807](https://github.com/Apipie/apipie-rails/pull/807) (Mathieu Jobin)
|
11
|
+
* [Fix] Reverted conditional assignment operators that caused #559 [#806](https://github.com/Apipie/apipie-rails/pull/806) (Nick L. Deltik)
|
12
|
+
* [Rubocop] Autocorrect Style/SymbolProc [#793](https://github.com/Apipie/apipie-rails/pull/793) (Rubocop Challenger)
|
8
13
|
|
9
14
|
## [v0.9.0](https://github.com/Apipie/apipie-rails/tree/v0.9.0) (2023-01-03)
|
10
15
|
[Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.8.2...v0.9.0)
|
data/README.rst
CHANGED
@@ -150,7 +150,7 @@ Example:
|
|
150
150
|
resource_description do
|
151
151
|
short 'Site members'
|
152
152
|
formats ['json']
|
153
|
-
param :id,
|
153
|
+
param :id, Integer, :desc => "User ID", :required => false
|
154
154
|
param :resource_param, Hash, :desc => 'Param description for all methods' do
|
155
155
|
param :ausername, String, :desc => "Username for login", :required => true
|
156
156
|
param :apassword, String, :desc => "Password for login", :required => true
|
@@ -1375,7 +1375,7 @@ So we create apipie_validators.rb initializer with this content:
|
|
1375
1375
|
end
|
1376
1376
|
|
1377
1377
|
def self.build(param_description, argument, options, block)
|
1378
|
-
if argument == Integer
|
1378
|
+
if argument == Integer
|
1379
1379
|
self.new(param_description, argument)
|
1380
1380
|
end
|
1381
1381
|
end
|
@@ -177,7 +177,7 @@ module Apipie
|
|
177
177
|
end
|
178
178
|
|
179
179
|
cache_file = File.join(Apipie.configuration.cache_dir, path)
|
180
|
-
if File.
|
180
|
+
if File.exist?(cache_file)
|
181
181
|
content_type = case params[:format]
|
182
182
|
when "json" then "application/json"
|
183
183
|
else "text/html"
|
data/lib/apipie/application.rb
CHANGED
@@ -242,13 +242,13 @@ module Apipie
|
|
242
242
|
|
243
243
|
# initialize variables for gathering dsl data
|
244
244
|
def init_env
|
245
|
-
@resource_descriptions
|
246
|
-
@controller_to_resource_id
|
247
|
-
@param_groups
|
245
|
+
@resource_descriptions = HashWithIndifferentAccess.new { |h, version| h[version] = {} }
|
246
|
+
@controller_to_resource_id = {}
|
247
|
+
@param_groups = {}
|
248
248
|
@swagger_generator = Apipie::SwaggerGenerator.new(self)
|
249
249
|
|
250
250
|
# what versions does the controller belong in (specified by resource_description)?
|
251
|
-
@controller_versions
|
251
|
+
@controller_versions = Hash.new { |h, controller| h[controller.to_s] = [] }
|
252
252
|
end
|
253
253
|
|
254
254
|
def recorded_examples
|
@@ -139,7 +139,7 @@ module Apipie
|
|
139
139
|
#
|
140
140
|
# Example:
|
141
141
|
# api :desc => "Show user profile", :path => "/users/", :version => '1.0 - 3.4.2012'
|
142
|
-
# param :id,
|
142
|
+
# param :id, Integer, :desc => "User ID", :required => true
|
143
143
|
# desc <<-EOS
|
144
144
|
# Long description...
|
145
145
|
# EOS
|
@@ -190,7 +190,7 @@ module Apipie
|
|
190
190
|
end
|
191
191
|
|
192
192
|
def load_old_examples
|
193
|
-
if File.
|
193
|
+
if File.exist?(@examples_file)
|
194
194
|
if defined? SafeYAML
|
195
195
|
return YAML.load_file(@examples_file, :safe=>false)
|
196
196
|
else
|
@@ -295,7 +295,7 @@ module Apipie
|
|
295
295
|
end
|
296
296
|
|
297
297
|
def controller_content
|
298
|
-
raise ControllerNotFound.new unless controller_path && File.
|
298
|
+
raise ControllerNotFound.new unless controller_path && File.exist?(controller_path)
|
299
299
|
@controller_content ||= File.read(controller_path)
|
300
300
|
end
|
301
301
|
|
@@ -35,7 +35,7 @@ module Apipie
|
|
35
35
|
|
36
36
|
@params_ordered = dsl_data[:params].map do |args|
|
37
37
|
Apipie::ParamDescription.from_dsl_data(self, args)
|
38
|
-
end.reject
|
38
|
+
end.reject(&:response_only?)
|
39
39
|
|
40
40
|
@params_ordered = ParamDescription.unify(@params_ordered)
|
41
41
|
@headers = dsl_data[:headers]
|
@@ -84,7 +84,7 @@ module Apipie
|
|
84
84
|
parent = Apipie.get_resource_description(@resource.controller.superclass)
|
85
85
|
|
86
86
|
# get tags from parent resource description
|
87
|
-
parent_tags = [parent, @resource].compact.flat_map
|
87
|
+
parent_tags = [parent, @resource].compact.flat_map(&:_tag_list_arg)
|
88
88
|
Apipie::TagListDescription.new((parent_tags + @tag_list).uniq.compact)
|
89
89
|
end
|
90
90
|
|
@@ -7,7 +7,7 @@ module Apipie
|
|
7
7
|
# path - relative path (/api/articles)
|
8
8
|
# methods - array of keys to Apipie.method_descriptions (array of Apipie::MethodDescription)
|
9
9
|
# name - human readable alias of resource (Articles)
|
10
|
-
# id -
|
10
|
+
# id - resource name
|
11
11
|
# formats - acceptable request/response format types
|
12
12
|
# headers - array of headers
|
13
13
|
# deprecated - boolean indicating if resource is deprecated
|
data/lib/apipie/version.rb
CHANGED
data/lib/tasks/apipie.rake
CHANGED
@@ -85,7 +85,7 @@ namespace :apipie do
|
|
85
85
|
counter = 1
|
86
86
|
make_reference = true
|
87
87
|
else
|
88
|
-
reference_files.sort_by!
|
88
|
+
reference_files.sort_by!(&:ctime)
|
89
89
|
last_ref = reference_files[-1]
|
90
90
|
print "Comparing [#{path}] to reference file: [#{last_ref.basename}]: "
|
91
91
|
if !FileUtils.compare_file(path, last_ref)
|
@@ -108,7 +108,7 @@ namespace :apipie do
|
|
108
108
|
|
109
109
|
num_refs_to_keep = 3
|
110
110
|
if reference_files.length > num_refs_to_keep
|
111
|
-
(reference_files - reference_files[-num_refs_to_keep..-1]).each
|
111
|
+
(reference_files - reference_files[-num_refs_to_keep..-1]).each(&:delete)
|
112
112
|
end
|
113
113
|
}
|
114
114
|
end
|
@@ -253,7 +253,7 @@ describe Apipie::ApipiesController do
|
|
253
253
|
let(:cache_dir) { File.join(Rails.root, "tmp", "apipie-cache") }
|
254
254
|
|
255
255
|
before do
|
256
|
-
FileUtils.rm_r(cache_dir) if File.
|
256
|
+
FileUtils.rm_r(cache_dir) if File.exist?(cache_dir)
|
257
257
|
FileUtils.mkdir_p(File.join(cache_dir, "apidoc", "v1", "resource"))
|
258
258
|
File.open(File.join(cache_dir, "apidoc", "v1.html"), "w") { |f| f << "apidoc.html cache v1" }
|
259
259
|
File.open(File.join(cache_dir, "apidoc", "v2.html"), "w") { |f| f << "apidoc.html cache v2" }
|
@@ -272,7 +272,7 @@ describe Apipie::ApipiesController do
|
|
272
272
|
Apipie.configuration.use_cache = false
|
273
273
|
Apipie.configuration.default_version = @orig_version
|
274
274
|
Apipie.configuration.cache_dir = @orig_cache_dir
|
275
|
-
# FileUtils.rm_r(cache_dir) if File.
|
275
|
+
# FileUtils.rm_r(cache_dir) if File.exist?(cache_dir)
|
276
276
|
end
|
277
277
|
|
278
278
|
it "uses the file in cache dir instead of generating the content on runtime" do
|
@@ -51,7 +51,7 @@ describe UsersController do
|
|
51
51
|
expect(subject._params_args.count).to eq(2)
|
52
52
|
name, type, options = subject._params_args.first
|
53
53
|
expect(name).to eq(:id)
|
54
|
-
expect(type).to eq(
|
54
|
+
expect(type).to eq(Integer)
|
55
55
|
expect(options).to eq({:required=>false, :desc=>"User ID"})
|
56
56
|
end
|
57
57
|
end
|
@@ -4,7 +4,7 @@ class UsersController < ApplicationController
|
|
4
4
|
short 'Site members'
|
5
5
|
path '/users'
|
6
6
|
formats ['json']
|
7
|
-
param :id,
|
7
|
+
param :id, Integer, :desc => "User ID", :required => false
|
8
8
|
param :legacy_param, Hash, :desc => 'Deprecated parameter not documented', :show => false, :required => false do
|
9
9
|
param :resource_param, Hash, :desc => 'Param description for all methods' do
|
10
10
|
param :ausername, String, :desc => "Username for login", :required => true
|
@@ -23,7 +23,7 @@ Apipie.configure do |config|
|
|
23
23
|
# rake apipie:cache
|
24
24
|
#
|
25
25
|
config.use_cache = Rails.env.production?
|
26
|
-
|
26
|
+
config.cache_dir = File.join(Rails.root, "tmp", "apipie-cache") # optional
|
27
27
|
|
28
28
|
# set to enable/disable reloading controllers (and the documentation with it),
|
29
29
|
# by default enabled in development
|
@@ -89,7 +89,7 @@ class Apipie::Validator::IntegerValidator < Apipie::Validator::BaseValidator
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def self.build(param_description, argument, options, block)
|
92
|
-
if argument == Integer
|
92
|
+
if argument == Integer
|
93
93
|
self.new(param_description, argument)
|
94
94
|
end
|
95
95
|
end
|
@@ -374,7 +374,7 @@ describe Apipie::ParamDescription do
|
|
374
374
|
|
375
375
|
subject do
|
376
376
|
Apipie::ParamDescription.new(method_desc, :param, Hash) do
|
377
|
-
param :answer,
|
377
|
+
param :answer, Integer
|
378
378
|
end
|
379
379
|
end
|
380
380
|
|
@@ -392,7 +392,7 @@ describe Apipie::ParamDescription do
|
|
392
392
|
|
393
393
|
subject do
|
394
394
|
Apipie::ParamDescription.new(method_desc, :param, Array) do
|
395
|
-
param :answer,
|
395
|
+
param :answer, Integer
|
396
396
|
end
|
397
397
|
end
|
398
398
|
|
@@ -422,9 +422,9 @@ describe Apipie::ParamDescription do
|
|
422
422
|
|
423
423
|
describe "Array with classes" do
|
424
424
|
it "should be valid for objects included in class array" do
|
425
|
-
param = Apipie::ParamDescription.new(method_desc, :param, [
|
425
|
+
param = Apipie::ParamDescription.new(method_desc, :param, [Integer, String])
|
426
426
|
expect { param.validate("1") }.not_to raise_error
|
427
|
-
expect { param.validate(
|
427
|
+
expect { param.validate(Integer) }.to raise_error(Apipie::ParamInvalid)
|
428
428
|
end
|
429
429
|
end
|
430
430
|
|
data/spec/lib/rake_spec.rb
CHANGED
@@ -49,9 +49,7 @@ describe 'rake tasks' do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
describe 'apipie:cache' do
|
52
|
-
let(:cache_output)
|
53
|
-
File.join(::Rails.root, 'public', 'apipie-cache')
|
54
|
-
end
|
52
|
+
let(:cache_output) { Apipie.configuration.cache_dir }
|
55
53
|
|
56
54
|
let(:apidoc_html) do
|
57
55
|
File.read("#{cache_output}.html")
|
data/spec/lib/validator_spec.rb
CHANGED
@@ -69,7 +69,7 @@ describe Apipie::Validator do
|
|
69
69
|
|
70
70
|
describe 'ArrayClassValidator' do
|
71
71
|
it "should validate by object class" do
|
72
|
-
validator = Apipie::Validator::ArrayClassValidator.new(params_desc, [
|
72
|
+
validator = Apipie::Validator::ArrayClassValidator.new(params_desc, [Integer, String])
|
73
73
|
expect(validator.validate("1")).to be_truthy
|
74
74
|
expect(validator.validate(1)).to be_truthy
|
75
75
|
expect(validator.validate({ 1 => 1 })).to be_falsey
|
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.9.
|
4
|
+
version: 0.9.1
|
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: 2023-01-
|
12
|
+
date: 2023-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|