apipie-rails 0.7.1 → 0.8.1
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 +4 -4
- data/.github/workflows/build.yml +3 -0
- data/CHANGELOG.md +21 -0
- data/README.rst +5 -0
- data/app/controllers/apipie/apipies_controller.rb +1 -1
- data/app/public/apipie/javascripts/bundled/bootstrap-collapse.js +70 -41
- data/app/public/apipie/javascripts/bundled/bootstrap.js +1033 -479
- data/app/public/apipie/javascripts/bundled/jquery.js +5 -5
- data/app/public/apipie/stylesheets/bundled/bootstrap-responsive.min.css +9 -12
- data/app/public/apipie/stylesheets/bundled/bootstrap.min.css +9 -689
- data/config/locales/ko.yml +31 -0
- data/gemfiles/Gemfile.rails70 +17 -0
- data/lib/apipie/application.rb +6 -4
- data/lib/apipie/configuration.rb +2 -1
- data/lib/apipie/dsl_definition.rb +1 -1
- data/lib/apipie/extractor/recorder.rb +1 -1
- data/lib/apipie/extractor.rb +2 -8
- data/lib/apipie/rspec/response_validation_helper.rb +2 -2
- data/lib/apipie/swagger_generator.rb +10 -2
- data/lib/apipie/version.rb +1 -1
- data/spec/dummy/app/controllers/concerns_controller.rb +1 -1
- data/spec/dummy/app/controllers/{concerns/extending_concern.rb → extending_concern.rb} +0 -2
- data/spec/dummy/app/controllers/overridden_concerns_controller.rb +2 -2
- data/spec/dummy/app/controllers/{concerns/sample_controller.rb → sample_controller.rb} +0 -2
- data/spec/dummy/config/application.rb +1 -1
- data/spec/spec_helper.rb +0 -32
- metadata +7 -6
- data/spec/support/rails-42-ruby-26.rb +0 -15
@@ -0,0 +1,31 @@
|
|
1
|
+
ko:
|
2
|
+
apipie:
|
3
|
+
resources: 리소스
|
4
|
+
resource: 리소스
|
5
|
+
description: 설명
|
6
|
+
no_docs_found: 문서를 찾을 수 없습니다.
|
7
|
+
no_docs_found_descr: 해당 API에 대한 문서를 찾을 수 없습니다.
|
8
|
+
follow_instructions_html: 해당 컨트롤러의 설명을 %{href}를 따르세요.
|
9
|
+
follow_instructions_href: 자세한 설명
|
10
|
+
oops: 이런!!
|
11
|
+
resource_not_found_html: "%{resource} 리소스를 찾을 수 없습니다."
|
12
|
+
method_not_found_html: "%{resource} 리소스에 대한 %{method} 메소드를 찾을 수 없습니다."
|
13
|
+
goto_homepage_html: "%{href}로 시도해보세요."
|
14
|
+
goto_homepage_href: "%{app_name} API 문서 페이지"
|
15
|
+
required: 필수
|
16
|
+
optional: 옵션
|
17
|
+
nil_allowed: nil 허용
|
18
|
+
param_name: Param 이름
|
19
|
+
params: Params
|
20
|
+
examples: 예시
|
21
|
+
metadata: Metadata
|
22
|
+
errors: 에러
|
23
|
+
error_code: 코드
|
24
|
+
error_description: 설명
|
25
|
+
error_metadata: Metadata
|
26
|
+
supported_formats: 지원 포멧
|
27
|
+
enable_javascript_html: "%{comments_href}를 보기 위해서 JavaScript를 허용해주세요."
|
28
|
+
comments_powered_by_disqus: comments powered by %{disqus}
|
29
|
+
api_documentation: API 문서
|
30
|
+
headers: 헤더
|
31
|
+
header_name: 헤더 이름
|
@@ -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
|
data/lib/apipie/application.rb
CHANGED
@@ -40,8 +40,10 @@ module Apipie
|
|
40
40
|
flatten_routes = []
|
41
41
|
|
42
42
|
route_set.routes.each do |route|
|
43
|
-
#
|
44
|
-
|
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
|
461
|
+
Rails.application.reloader.reload!
|
460
462
|
init_env
|
461
463
|
reload_examples
|
462
|
-
Rails
|
464
|
+
Rails.application.reloader.prepare!
|
463
465
|
end
|
464
466
|
end
|
465
467
|
|
data/lib/apipie/configuration.rb
CHANGED
@@ -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
|
|
@@ -150,7 +150,7 @@ module Apipie
|
|
150
150
|
end
|
151
151
|
|
152
152
|
module FunctionalTestRecording
|
153
|
-
def process(
|
153
|
+
def process(*) # action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
|
154
154
|
ret = super
|
155
155
|
if Apipie.configuration.record
|
156
156
|
Apipie::Extractor.call_recorder.analyze_functional_test(self)
|
data/lib/apipie/extractor.rb
CHANGED
@@ -17,14 +17,8 @@ class Apipie::Railtie
|
|
17
17
|
end
|
18
18
|
app.middleware.use ::Apipie::Extractor::Recorder::Middleware
|
19
19
|
|
20
|
-
|
21
|
-
|
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
|
|
@@ -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(
|
165
|
-
result = super
|
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
|
-
|
481
|
-
|
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
|
|
data/lib/apipie/version.rb
CHANGED
@@ -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
|
6
|
+
include SampleController
|
7
7
|
|
8
8
|
end
|
@@ -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
|
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,
|
14
|
+
param_group :concern, SampleController
|
15
15
|
def update
|
16
16
|
super
|
17
17
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -10,37 +10,6 @@ require 'rspec/rails'
|
|
10
10
|
require 'apipie-rails'
|
11
11
|
require 'test_engine'
|
12
12
|
|
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
13
|
#
|
45
14
|
# Matcher to validate the properties (name, type and options) of a single field in the
|
46
15
|
# internal representation of a swagger schema
|
@@ -114,4 +83,3 @@ RSpec.configure do |config|
|
|
114
83
|
end
|
115
84
|
|
116
85
|
require 'action_controller/test_case.rb'
|
117
|
-
ActionController::TestCase::Behavior.send(:prepend, Rails4Compatibility::Testing)
|
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.
|
4
|
+
version: 0.8.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: 2022-
|
12
|
+
date: 2022-05-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- config/locales/fr.yml
|
205
205
|
- config/locales/it.yml
|
206
206
|
- config/locales/ja.yml
|
207
|
+
- config/locales/ko.yml
|
207
208
|
- config/locales/pl.yml
|
208
209
|
- config/locales/pt-BR.yml
|
209
210
|
- config/locales/ru.yml
|
@@ -215,6 +216,7 @@ files:
|
|
215
216
|
- gemfiles/Gemfile.rails52
|
216
217
|
- gemfiles/Gemfile.rails60
|
217
218
|
- gemfiles/Gemfile.rails61
|
219
|
+
- gemfiles/Gemfile.rails70
|
218
220
|
- images/screenshot-1.png
|
219
221
|
- images/screenshot-2.png
|
220
222
|
- lib/apipie-rails.rb
|
@@ -273,15 +275,15 @@ files:
|
|
273
275
|
- spec/dummy/app/controllers/api/v2/nested/architectures_controller.rb
|
274
276
|
- spec/dummy/app/controllers/api/v2/nested/resources_controller.rb
|
275
277
|
- spec/dummy/app/controllers/application_controller.rb
|
276
|
-
- spec/dummy/app/controllers/concerns/extending_concern.rb
|
277
|
-
- spec/dummy/app/controllers/concerns/sample_controller.rb
|
278
278
|
- spec/dummy/app/controllers/concerns_controller.rb
|
279
279
|
- spec/dummy/app/controllers/extended_controller.rb
|
280
|
+
- spec/dummy/app/controllers/extending_concern.rb
|
280
281
|
- spec/dummy/app/controllers/files_controller.rb
|
281
282
|
- spec/dummy/app/controllers/overridden_concerns_controller.rb
|
282
283
|
- spec/dummy/app/controllers/pets_controller.rb
|
283
284
|
- spec/dummy/app/controllers/pets_using_auto_views_controller.rb
|
284
285
|
- spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb
|
286
|
+
- spec/dummy/app/controllers/sample_controller.rb
|
285
287
|
- spec/dummy/app/controllers/tagged_cats_controller.rb
|
286
288
|
- spec/dummy/app/controllers/tagged_dogs_controller.rb
|
287
289
|
- spec/dummy/app/controllers/twitter_example_controller.rb
|
@@ -336,7 +338,6 @@ files:
|
|
336
338
|
- spec/lib/validator_spec.rb
|
337
339
|
- spec/lib/validators/array_validator_spec.rb
|
338
340
|
- spec/spec_helper.rb
|
339
|
-
- spec/support/rails-42-ruby-26.rb
|
340
341
|
- spec/support/rake.rb
|
341
342
|
homepage: http://github.com/Apipie/apipie-rails
|
342
343
|
licenses: []
|
@@ -356,7 +357,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
356
357
|
- !ruby/object:Gem::Version
|
357
358
|
version: '0'
|
358
359
|
requirements: []
|
359
|
-
rubygems_version: 3.
|
360
|
+
rubygems_version: 3.2.33
|
360
361
|
signing_key:
|
361
362
|
specification_version: 4
|
362
363
|
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
|
-
|