oas_rails 1.3.1 → 1.3.3
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/app/helpers/oas_rails/oas_rails_helper.rb +1 -1
- data/app/views/oas_rails/oas_rails/index.html.erb +8 -8
- data/lib/oas_rails/builders/oas_route_builder.rb +1 -1
- data/lib/oas_rails/configuration.rb +14 -13
- data/lib/oas_rails/extractors/route_extractor.rb +5 -16
- data/lib/oas_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6c57b944ffe2fb0d046fe76ad471318081affa50700e3a0a5624358565b40948
|
|
4
|
+
data.tar.gz: b7e8804ef0c310c7b7c934341f857d1819757ea767c46d9c9d81c954780a8f75
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 14d613c551e766cfba12bfea87e5ab61ca7bf895c4e540405e3114659e1b847432ab8d2df40afdedc9df1464ab89deb5a2ffacadffb6fb6872c0e50b8d211da0
|
|
7
|
+
data.tar.gz: aa9d4b8ee57ddcacc312a5b0d8e618b77636c284fbf9fd01bc281c07a27c6d2eaf624da765b04ba3f89d4c975d36a174b830b8b9f960c723040ce34b03b0e560
|
|
@@ -2,7 +2,7 @@ module OasRails
|
|
|
2
2
|
module OasRailsHelper # rubocop:disable Metrics/ModuleLength
|
|
3
3
|
def rapidoc_configuration_defaults
|
|
4
4
|
{
|
|
5
|
-
"spec-url" => "#{OasRails.
|
|
5
|
+
"spec-url" => "#{OasRails::Engine.routes.find_script_name(params.permit!.to_h.symbolize_keys)}.json",
|
|
6
6
|
"show-header" => "false",
|
|
7
7
|
"font-size" => "largest",
|
|
8
8
|
"show-method-in-nav-bar" => "as-colored-text",
|
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
<title><%= OasRails.config.info.title %></title>
|
|
5
5
|
<%= csrf_meta_tags %>
|
|
6
6
|
<%= csp_meta_tag %>
|
|
7
|
-
<meta charset="utf-8">
|
|
8
7
|
<!-- Important: rapi-doc uses utf8 characters -->
|
|
9
|
-
<
|
|
8
|
+
<meta charset="utf-8">
|
|
9
|
+
<script
|
|
10
|
+
type="module"
|
|
11
|
+
src="<%= OasRails.config.prefix_path %>/oas-rails-assets/rapidoc-min.js"
|
|
12
|
+
></script>
|
|
10
13
|
</head>
|
|
11
14
|
<body>
|
|
12
|
-
<rapi-doc <%= rapidoc_configuration_attributes
|
|
15
|
+
<rapi-doc <%= rapidoc_configuration_attributes %>>
|
|
13
16
|
<% if rapidoc_logo_url %>
|
|
14
|
-
<img
|
|
15
|
-
slot="nav-logo"
|
|
16
|
-
src="<%= rapidoc_logo_url %>"
|
|
17
|
-
/>
|
|
17
|
+
<img slot="nav-logo" src="<%= rapidoc_logo_url %>"/>
|
|
18
18
|
<% end %>
|
|
19
19
|
</rapi-doc>
|
|
20
20
|
|
|
21
|
-
<%= render partial:
|
|
21
|
+
<%= render partial: "rapidoc_style_parts" %>
|
|
22
22
|
</body>
|
|
23
23
|
</html>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
module OasRails
|
|
2
2
|
class Configuration < OasCore::Configuration
|
|
3
|
-
attr_accessor :autodiscover_request_body, :autodiscover_responses, :ignored_actions, :rapidoc_theme, :layout, :source_oas_path, :rapidoc_configuration, :rapidoc_logo_url
|
|
4
|
-
attr_reader :route_extractor, :include_mode
|
|
3
|
+
attr_accessor :autodiscover_request_body, :autodiscover_responses, :ignored_actions, :rapidoc_theme, :layout, :source_oas_path, :rapidoc_configuration, :rapidoc_logo_url
|
|
4
|
+
attr_reader :route_extractor, :include_mode, :mounted_path, :prefix_path
|
|
5
5
|
|
|
6
6
|
def initialize
|
|
7
7
|
super
|
|
8
|
-
@mounted_path =
|
|
8
|
+
@mounted_path = ""
|
|
9
|
+
self.prefix_path = ENV["RAILS_RELATIVE_URL_ROOT"] || Rails.application.config.relative_url_root || ""
|
|
9
10
|
@route_extractor = Extractors::RouteExtractor
|
|
10
11
|
@include_mode = :all
|
|
11
12
|
@autodiscover_request_body = true
|
|
@@ -22,6 +23,10 @@ module OasRails
|
|
|
22
23
|
# autodiscover_responses
|
|
23
24
|
end
|
|
24
25
|
|
|
26
|
+
def mounted_path=(_value)
|
|
27
|
+
warn "[DEPRECATION] `mounted_path` option is deprecated and will be removed in a future release. It is not used anymore."
|
|
28
|
+
end
|
|
29
|
+
|
|
25
30
|
def excluded_columns_incoming
|
|
26
31
|
%i[id created_at updated_at deleted_at]
|
|
27
32
|
end
|
|
@@ -50,16 +55,12 @@ module OasRails
|
|
|
50
55
|
@route_extractor = value
|
|
51
56
|
end
|
|
52
57
|
|
|
53
|
-
def
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
mount_route.path.spec.to_s.sub(/\(\.:format\)\z/, '')
|
|
60
|
-
else
|
|
61
|
-
'/docs'
|
|
62
|
-
end
|
|
58
|
+
def prefix_path=(value)
|
|
59
|
+
@prefix_path = if value.nil? || value.empty?
|
|
60
|
+
""
|
|
61
|
+
else
|
|
62
|
+
value.start_with?("/") ? value : "/#{value}"
|
|
63
|
+
end
|
|
63
64
|
end
|
|
64
65
|
end
|
|
65
66
|
end
|
|
@@ -2,21 +2,11 @@ module OasRails
|
|
|
2
2
|
module Extractors
|
|
3
3
|
class RouteExtractor
|
|
4
4
|
RAILS_DEFAULT_CONTROLLERS = %w[
|
|
5
|
-
rails
|
|
6
|
-
|
|
7
|
-
active_storage/blobs
|
|
8
|
-
active_storage/disk
|
|
9
|
-
active_storage/direct_uploads
|
|
10
|
-
active_storage/representations
|
|
11
|
-
rails/conductor/continuous_integration
|
|
12
|
-
rails/conductor/multiple_databases
|
|
13
|
-
rails/conductor/action_mailbox
|
|
14
|
-
rails/conductor/action_text
|
|
5
|
+
rails
|
|
6
|
+
action_mailbox
|
|
15
7
|
action_cable
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
RAILS_DEFAULT_PATHS = %w[
|
|
19
|
-
/rails/action_mailbox/
|
|
8
|
+
active_storage
|
|
9
|
+
turbo/native
|
|
20
10
|
].freeze
|
|
21
11
|
|
|
22
12
|
class << self
|
|
@@ -64,7 +54,6 @@ module OasRails
|
|
|
64
54
|
def valid_api_route?(route)
|
|
65
55
|
return false unless valid_route_implementation?(route)
|
|
66
56
|
return false if RAILS_DEFAULT_CONTROLLERS.any? { |default| route.defaults[:controller].start_with?(default) }
|
|
67
|
-
return false if RAILS_DEFAULT_PATHS.any? { |path| route.path.spec.to_s.include?(path) }
|
|
68
57
|
return false unless route.path.spec.to_s.start_with?(OasRails.config.api_path)
|
|
69
58
|
return false if ignore_custom_actions?(route)
|
|
70
59
|
|
|
@@ -90,7 +79,7 @@ module OasRails
|
|
|
90
79
|
if controller_class.nil?
|
|
91
80
|
false
|
|
92
81
|
else
|
|
93
|
-
controller_class.
|
|
82
|
+
controller_class.method_defined?(action_name.to_sym)
|
|
94
83
|
end
|
|
95
84
|
end
|
|
96
85
|
|
data/lib/oas_rails/version.rb
CHANGED