oas_rails 0.17.1 → 1.0.0
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/lib/oas_rails/configuration.rb +10 -1
- data/lib/oas_rails/extractors/route_extractor.rb +2 -2
- data/lib/oas_rails/version.rb +1 -1
- data/lib/oas_rails.rb +13 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d23aa895481ff8d0bd25e9d681dcc2bb5738b26306b78a9e76d9366959898e0b
|
4
|
+
data.tar.gz: f8160302249f30abd9959c11ce365b5ad5992f7b7b14c5a1ab1cba53ee0ababd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2428433ef2f680ad3a0c7ec4a72b1eeaced918977fd5db5fa4919047784583e6cf7369d77091056817ee48cb1597922785c94e53b7ddf8fe00b0ea7d8ef848d4
|
7
|
+
data.tar.gz: b046fb2101c8f521c6d5e8b41eae979d363a311355a58dec5ccec6802e4ad4521b9c0f1a5186d525692a8c7df6d1ed1a50afcbc31c54b7bf5d661906d404a168
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module OasRails
|
2
2
|
class Configuration < OasCore::Configuration
|
3
|
-
attr_accessor :autodiscover_request_body, :autodiscover_responses, :ignored_actions, :rapidoc_theme, :layout
|
3
|
+
attr_accessor :autodiscover_request_body, :autodiscover_responses, :ignored_actions, :rapidoc_theme, :layout, :source_oas_path
|
4
4
|
attr_reader :route_extractor, :include_mode
|
5
5
|
|
6
6
|
def initialize
|
@@ -12,12 +12,21 @@ module OasRails
|
|
12
12
|
@ignored_actions = []
|
13
13
|
@rapidoc_theme = :rails
|
14
14
|
@layout = nil
|
15
|
+
@source_oas_path = nil
|
15
16
|
|
16
17
|
# TODO: implement
|
17
18
|
# autodiscover_request_body
|
18
19
|
# autodiscover_responses
|
19
20
|
end
|
20
21
|
|
22
|
+
def excluded_columns_incoming
|
23
|
+
%i[id created_at updated_at deleted_at]
|
24
|
+
end
|
25
|
+
|
26
|
+
def excluded_columns_outgoing
|
27
|
+
[]
|
28
|
+
end
|
29
|
+
|
21
30
|
def include_mode=(value)
|
22
31
|
valid_modes = %i[all with_tags explicit]
|
23
32
|
raise ArgumentError, "include_mode must be one of #{valid_modes}" unless valid_modes.include?(value)
|
@@ -66,7 +66,7 @@ module OasRails
|
|
66
66
|
return false if RAILS_DEFAULT_CONTROLLERS.any? { |default| route.defaults[:controller].start_with?(default) }
|
67
67
|
return false if RAILS_DEFAULT_PATHS.any? { |path| route.path.spec.to_s.include?(path) }
|
68
68
|
return false unless route.path.spec.to_s.start_with?(OasRails.config.api_path)
|
69
|
-
return false if ignore_custom_actions(route)
|
69
|
+
return false if ignore_custom_actions?(route)
|
70
70
|
|
71
71
|
true
|
72
72
|
end
|
@@ -99,7 +99,7 @@ module OasRails
|
|
99
99
|
# Support controller name only to ignore all controller actions.
|
100
100
|
# Support ignoring "controller#action"
|
101
101
|
# Ignoring "controller#action" AND "api_path/controller#action"
|
102
|
-
def ignore_custom_actions(route)
|
102
|
+
def ignore_custom_actions?(route)
|
103
103
|
api_path = "#{OasRails.config.api_path.sub(%r{\A/}, '')}/".sub(%r{/+$}, '/')
|
104
104
|
ignored_actions = OasRails.config.ignored_actions.flat_map do |custom_route|
|
105
105
|
if custom_route.start_with?(api_path)
|
data/lib/oas_rails/version.rb
CHANGED
data/lib/oas_rails.rb
CHANGED
@@ -34,9 +34,9 @@ module OasRails
|
|
34
34
|
OasCore.config = config
|
35
35
|
|
36
36
|
host_routes = Extractors::RouteExtractor.host_routes
|
37
|
-
|
37
|
+
oas_source = config.source_oas_path ? read_source_oas_file : {}
|
38
38
|
|
39
|
-
|
39
|
+
OasCore.build(host_routes, oas_source: oas_source)
|
40
40
|
end
|
41
41
|
|
42
42
|
def configure
|
@@ -47,11 +47,22 @@ module OasRails
|
|
47
47
|
@config ||= Configuration.new
|
48
48
|
end
|
49
49
|
|
50
|
+
private
|
51
|
+
|
50
52
|
def clear_cache
|
51
53
|
return if Rails.env.production?
|
52
54
|
|
53
55
|
MethodSource.clear_cache
|
54
56
|
OasRails::Extractors::RouteExtractor.clear_cache
|
55
57
|
end
|
58
|
+
|
59
|
+
def read_source_oas_file
|
60
|
+
file_path = Rails.root.join(config.source_oas_path)
|
61
|
+
JSON.parse(File.read(file_path), symbolize_names: true)
|
62
|
+
rescue Errno::ENOENT => e
|
63
|
+
raise "Failed to read source OAS file at #{file_path}: #{e.message}"
|
64
|
+
rescue JSON::ParserError => e
|
65
|
+
raise "Failed to parse source OAS file at #{file_path}: #{e.message}"
|
66
|
+
end
|
56
67
|
end
|
57
68
|
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: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- a-chacon
|
@@ -29,14 +29,14 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 1.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
39
|
+
version: 1.0.0
|
40
40
|
description: OasRails is a Rails engine for generating automatic interactive documentation
|
41
41
|
for your Rails APIs. It generates an OAS 3.1 document and displays it using RapiDoc.
|
42
42
|
email:
|