oas_rails 1.3.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0b3910279e971e6003cfedc98449efb5c4a5c9a60de1cfcb101bd5ef24ac7de
4
- data.tar.gz: ec5d068a23ade33e59bb170bb2631164da5fd891af8b97c796cdaefeaf76001c
3
+ metadata.gz: 6c57b944ffe2fb0d046fe76ad471318081affa50700e3a0a5624358565b40948
4
+ data.tar.gz: b7e8804ef0c310c7b7c934341f857d1819757ea767c46d9c9d81c954780a8f75
5
5
  SHA512:
6
- metadata.gz: bde3e335009615186c8ce30be0db4193f61da7a58ef73f94ed4ba6d819a247356e61f343e4168a6b835f68d16b9d6d3a0297a8a3616ebd640640a21dd5d18ec1
7
- data.tar.gz: b5db64d6e6370982e7e84421b19eb2b1e7ba16b60b774c1acae44952f9d4c46ff3347ab8456460bcfcef2293c59a151a86594a726eb1bf9bf5154a4de83b2509
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.config.mounted_path}.json",
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
- <script type="module" src="/oas-rails-assets/rapidoc-min.js"></script>
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: 'rapidoc_style_parts' %>
21
+ <%= render partial: "rapidoc_style_parts" %>
22
22
  </body>
23
23
  </html>
@@ -40,7 +40,7 @@ module OasRails
40
40
  end
41
41
 
42
42
  def path
43
- OasRails.config.route_extractor.clean_route(@rails_route.path.spec.to_s)
43
+ OasRails.config.prefix_path + OasRails.config.route_extractor.clean_route(@rails_route.path.spec.to_s)
44
44
  end
45
45
 
46
46
  def source_string
@@ -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, :mounted_path
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 = default_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 default_mounted_path
54
- mount_route = Rails.application.routes.routes.detect do |r|
55
- r.app.respond_to?(:app) && r.app.app == OasRails::Engine
56
- end
57
-
58
- if mount_route
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
@@ -79,7 +79,7 @@ module OasRails
79
79
  if controller_class.nil?
80
80
  false
81
81
  else
82
- controller_class.instance_methods.include?(action_name.to_sym)
82
+ controller_class.method_defined?(action_name.to_sym)
83
83
  end
84
84
  end
85
85
 
@@ -1,3 +1,3 @@
1
1
  module OasRails
2
- VERSION = "1.3.2"
2
+ VERSION = "1.3.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oas_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - a-chacon