r2-oas 0.1.2 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.rubocop.yml +6 -3
- data/.rubocop_todo.yml +68 -1
- data/.travis.yml +6 -2
- data/Appraisals +13 -0
- data/CHANGELOG.md +51 -0
- data/GEMSPEC.md +20 -0
- data/README.ja.md +71 -0
- data/README.md +70 -0
- data/lib/r2-oas.rb +3 -4
- data/lib/r2-oas/deploy/client.rb +33 -6
- data/lib/r2-oas/errors.rb +1 -0
- data/lib/r2-oas/lib/core_ext/hash/deep_merge.rb +44 -0
- data/lib/r2-oas/lib/core_ext/object/blank.rb +135 -0
- data/lib/r2-oas/lib/three-way-merge/twm.rb +83 -0
- data/lib/r2-oas/schema/builder.rb +23 -0
- data/lib/r2-oas/schema/editor.rb +26 -7
- data/lib/r2-oas/schema/generator.rb +1 -1
- data/lib/r2-oas/schema/manager/file_manager.rb +26 -0
- data/lib/r2-oas/schema/ui.rb +0 -1
- data/lib/r2-oas/schema/v3/analyzer/base_analyzer.rb +1 -6
- data/lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb +1 -1
- data/lib/r2-oas/schema/v3/analyzer/path_analyzer.rb +1 -1
- data/lib/r2-oas/schema/v3/analyzer/tag_analyzer.rb +1 -1
- data/lib/r2-oas/schema/v3/builder.rb +28 -0
- data/lib/r2-oas/schema/v3/builder/base_builder.rb +60 -0
- data/lib/r2-oas/schema/v3/builder/doc_builder.rb +43 -0
- data/lib/r2-oas/schema/v3/cleaner/base_cleaner.rb +1 -1
- data/lib/r2-oas/schema/v3/generator.rb +1 -5
- data/lib/r2-oas/schema/v3/generator/base_generator.rb +30 -1
- data/lib/r2-oas/schema/v3/generator/components/object_generator.rb +6 -25
- data/lib/r2-oas/schema/v3/generator/components/request_body_generator.rb +6 -6
- data/lib/r2-oas/schema/v3/generator/doc_generator.rb +84 -18
- data/lib/r2-oas/schema/v3/generator/path_generator.rb +7 -19
- data/lib/r2-oas/schema/v3/generator/schema_generator.rb +6 -26
- data/lib/r2-oas/schema/v3/manager/file/base_file_manager.rb +10 -4
- data/lib/r2-oas/schema/v3/manager/pathname_manager.rb +6 -1
- data/lib/r2-oas/store.rb +118 -0
- data/lib/r2-oas/task_logging.rb +6 -0
- data/lib/r2-oas/tasks/main.rake +66 -73
- data/lib/r2-oas/tasks/tool.rake +32 -28
- data/lib/r2-oas/tool/paths/ls.rb +1 -1
- data/lib/r2-oas/version.rb +1 -1
- data/r2-oas.gemspec +19 -10
- metadata +88 -60
- data/.github/ISSUE_TEMPLATE.md +0 -12
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -12
- data/Gemfile.lock +0 -222
- data/bin/console +0 -12
- data/bin/setup +0 -8
- data/docs/.nojekyll +0 -0
- data/docs/README.md +0 -326
- data/docs/_sidebar.md +0 -22
- data/docs/index.html +0 -28
- data/docs/schema/3.0.0.md +0 -155
- data/docs/setting/COC.md +0 -14
- data/docs/setting/CORS.md +0 -22
- data/docs/setting/configure.md +0 -163
- data/docs/usage/analyze_docs.md +0 -875
- data/docs/usage/clean_docs.md +0 -19
- data/docs/usage/deploy_docs.md +0 -839
- data/docs/usage/display_paths_list.md +0 -35
- data/docs/usage/display_paths_stats.md +0 -54
- data/docs/usage/edit_docs.md +0 -218
- data/docs/usage/generate_docs.md +0 -256
- data/docs/usage/monitor_docs.md +0 -219
- data/docs/usage/use_hook_methods.md +0 -236
- data/docs/usage/use_hook_to_generate_docs.md +0 -235
- data/docs/usage/use_schema_namespace.md +0 -183
- data/docs/usage/use_tag_namespace.md +0 -182
- data/docs/usage/view_docs.md +0 -262
- data/lib/r2-oas/deploy/swagger-ui/dist/favicon-16x16.png +0 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/favicon-32x32.png +0 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/oauth2-redirect.html +0 -68
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-bundle.js +0 -134
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-bundle.js.map +0 -1
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-standalone-preset.js +0 -22
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-standalone-preset.js.map +0 -1
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.css +0 -4
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.css.map +0 -1
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.js +0 -9
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.js.map +0 -1
data/lib/r2-oas.rb
CHANGED
@@ -6,14 +6,14 @@ require 'r2-oas/errors'
|
|
6
6
|
require 'r2-oas/schema/v3/object/public'
|
7
7
|
|
8
8
|
module R2OAS
|
9
|
-
extend ActiveSupport::Autoload
|
10
|
-
|
11
9
|
if !defined?(::Rails)
|
12
10
|
raise NoImplementError, 'Can not load Rails'
|
13
11
|
# support Rails version
|
14
12
|
elsif ::Rails::VERSION::STRING >= '4.2.5.1'
|
15
13
|
extend Configuration
|
16
14
|
require 'r2-oas/task'
|
15
|
+
require 'r2-oas/lib/core_ext/hash/deep_merge'
|
16
|
+
require 'r2-oas/lib/core_ext/object/blank'
|
17
17
|
|
18
18
|
autoload :Base, 'r2-oas/base'
|
19
19
|
autoload :NoImplementError, 'r2-oas/errors'
|
@@ -22,10 +22,9 @@ module R2OAS
|
|
22
22
|
autoload :Sortable, 'r2-oas/shared/all'
|
23
23
|
|
24
24
|
module Schema
|
25
|
-
extend ActiveSupport::Autoload
|
26
|
-
|
27
25
|
autoload :Base, 'r2-oas/schema/base'
|
28
26
|
autoload :Generator, 'r2-oas/schema/generator'
|
27
|
+
autoload :Builder, 'r2-oas/schema/builder'
|
29
28
|
autoload :Analyzer, 'r2-oas/schema/analyzer'
|
30
29
|
autoload :Squeezer, 'r2-oas/schema/squeezer'
|
31
30
|
autoload :Cleaner, 'r2-oas/schema/cleaner'
|
data/lib/r2-oas/deploy/client.rb
CHANGED
@@ -6,22 +6,33 @@ require 'fileutils'
|
|
6
6
|
module R2OAS
|
7
7
|
module Deploy
|
8
8
|
class Client < Schema::Base
|
9
|
+
SWAGGER_UI_DIST_URL = 'https://github.com/swagger-api/swagger-ui/trunk/dist'
|
10
|
+
|
11
|
+
def initialize(options = {})
|
12
|
+
super(options)
|
13
|
+
@download_dir = "#{SecureRandom.uuid[0..7]}/dist"
|
14
|
+
@dist_path = File.expand_path(Rails.root.join(@download_dir), __FILE__)
|
15
|
+
end
|
16
|
+
|
17
|
+
def download_swagger_ui_dist
|
18
|
+
system("svn export #{SWAGGER_UI_DIST_URL} #{@dist_path}")
|
19
|
+
end
|
20
|
+
|
9
21
|
def deploy
|
10
22
|
copy_swagger_ui_dist
|
11
23
|
copy_swagger_ui_index
|
12
24
|
copy_oas_doc_file
|
25
|
+
ensure
|
26
|
+
remove_download_dist
|
13
27
|
end
|
14
28
|
|
15
29
|
private
|
16
30
|
|
17
31
|
def copy_swagger_ui_dist
|
18
32
|
docs_path = File.expand_path(Rails.root.join(deploy_dir_path), __FILE__)
|
19
|
-
return if FileTest.exists?(docs_path)
|
20
|
-
|
21
33
|
FileUtils.mkdir_p(docs_path) unless FileTest.exists?(docs_path)
|
22
|
-
|
23
|
-
|
24
|
-
FileUtils.cp_r(dist_path, docs_path)
|
34
|
+
FileUtils.mkdir_p(@dist_path) unless FileTest.exists?(@dist_path)
|
35
|
+
FileUtils.cp_r(@dist_path, docs_path)
|
25
36
|
end
|
26
37
|
|
27
38
|
def copy_swagger_ui_index
|
@@ -29,7 +40,7 @@ module R2OAS
|
|
29
40
|
@schema_file_path = doc_save_file_name
|
30
41
|
template_path = File.expand_path('swagger-ui/index.html.erb', __dir__)
|
31
42
|
template = File.read(template_path)
|
32
|
-
index =
|
43
|
+
index = make_index(template)
|
33
44
|
File.write(index_path, index)
|
34
45
|
end
|
35
46
|
|
@@ -38,6 +49,22 @@ module R2OAS
|
|
38
49
|
oas_doc_file_path = File.expand_path("#{root_dir_path}/#{doc_save_file_name}")
|
39
50
|
FileUtils.cp_r(oas_doc_file_path, swagger_file_path)
|
40
51
|
end
|
52
|
+
|
53
|
+
def remove_download_dist
|
54
|
+
FileUtils.rm_rf(File.expand_path('..', @dist_path))
|
55
|
+
end
|
56
|
+
|
57
|
+
# [ref]
|
58
|
+
# https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Lint/ErbNewArguments
|
59
|
+
def make_index(template)
|
60
|
+
if RUBY_VERSION >= '2.6'
|
61
|
+
ERB.new(template, trim_mode: '%').result(binding)
|
62
|
+
else
|
63
|
+
# rubocop:disable Lint/ErbNewArguments
|
64
|
+
ERB.new(template, nil, trim_mode: '%').result(binding)
|
65
|
+
# rubocop:enable Lint/ErbNewArguments
|
66
|
+
end
|
67
|
+
end
|
41
68
|
end
|
42
69
|
end
|
43
70
|
end
|
data/lib/r2-oas/errors.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copy From https://github.com/rails/rails/blob/v4.2.5/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
|
4
|
+
|
5
|
+
# rubocop:disable all
|
6
|
+
class Hash
|
7
|
+
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
8
|
+
#
|
9
|
+
# h1 = { a: true, b: { c: [1, 2, 3] } }
|
10
|
+
# h2 = { a: false, b: { x: [3, 4, 5] } }
|
11
|
+
#
|
12
|
+
# h1.deep_merge(h2) #=> { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }
|
13
|
+
#
|
14
|
+
# Like with Hash#merge in the standard library, a block can be provided
|
15
|
+
# to merge values:
|
16
|
+
#
|
17
|
+
# h1 = { a: 100, b: 200, c: { c1: 100 } }
|
18
|
+
# h2 = { b: 250, c: { c1: 200 } }
|
19
|
+
# h1.deep_merge(h2) { |key, this_val, other_val| this_val + other_val }
|
20
|
+
# # => { a: 100, b: 450, c: { c1: 300 } }
|
21
|
+
def deep_merge(other_hash, &block)
|
22
|
+
dup.deep_merge!(other_hash, &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Same as +deep_merge+, but modifies +self+.
|
26
|
+
def deep_merge!(other_hash, &block)
|
27
|
+
other_hash.each_pair do |current_key, other_value|
|
28
|
+
this_value = self[current_key]
|
29
|
+
|
30
|
+
self[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash)
|
31
|
+
this_value.deep_merge(other_value, &block)
|
32
|
+
else
|
33
|
+
if block_given? && key?(current_key)
|
34
|
+
block.call(current_key, this_value, other_value)
|
35
|
+
else
|
36
|
+
other_value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
self
|
42
|
+
end
|
43
|
+
end
|
44
|
+
# rubocop:enable all
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copy From https://github.com/rails/rails/blob/v4.2.5/activesupport/lib/active_support/core_ext/object/blank.rb
|
4
|
+
|
5
|
+
# rubocop:disable all
|
6
|
+
class Object
|
7
|
+
# An object is blank if it's false, empty, or a whitespace string.
|
8
|
+
# For example, +false+, '', ' ', +nil+, [], and {} are all blank.
|
9
|
+
#
|
10
|
+
# This simplifies
|
11
|
+
#
|
12
|
+
# !address || address.empty?
|
13
|
+
#
|
14
|
+
# to
|
15
|
+
#
|
16
|
+
# address.blank?
|
17
|
+
#
|
18
|
+
# @return [true, false]
|
19
|
+
def blank?
|
20
|
+
respond_to?(:empty?) ? !!empty? : !self
|
21
|
+
end
|
22
|
+
|
23
|
+
# An object is present if it's not blank.
|
24
|
+
#
|
25
|
+
# @return [true, false]
|
26
|
+
def present?
|
27
|
+
!blank?
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns the receiver if it's present otherwise returns +nil+.
|
31
|
+
# <tt>object.presence</tt> is equivalent to
|
32
|
+
#
|
33
|
+
# object.present? ? object : nil
|
34
|
+
#
|
35
|
+
# For example, something like
|
36
|
+
#
|
37
|
+
# state = params[:state] if params[:state].present?
|
38
|
+
# country = params[:country] if params[:country].present?
|
39
|
+
# region = state || country || 'US'
|
40
|
+
#
|
41
|
+
# becomes
|
42
|
+
#
|
43
|
+
# region = params[:state].presence || params[:country].presence || 'US'
|
44
|
+
#
|
45
|
+
# @return [Object]
|
46
|
+
def presence
|
47
|
+
self if present?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class NilClass
|
52
|
+
# +nil+ is blank:
|
53
|
+
#
|
54
|
+
# nil.blank? # => true
|
55
|
+
#
|
56
|
+
# @return [true]
|
57
|
+
def blank?
|
58
|
+
true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class FalseClass
|
63
|
+
# +false+ is blank:
|
64
|
+
#
|
65
|
+
# false.blank? # => true
|
66
|
+
#
|
67
|
+
# @return [true]
|
68
|
+
def blank?
|
69
|
+
true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class TrueClass
|
74
|
+
# +true+ is not blank:
|
75
|
+
#
|
76
|
+
# true.blank? # => false
|
77
|
+
#
|
78
|
+
# @return [false]
|
79
|
+
def blank?
|
80
|
+
false
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class Array
|
85
|
+
# An array is blank if it's empty:
|
86
|
+
#
|
87
|
+
# [].blank? # => true
|
88
|
+
# [1,2,3].blank? # => false
|
89
|
+
#
|
90
|
+
# @return [true, false]
|
91
|
+
alias_method :blank?, :empty?
|
92
|
+
end
|
93
|
+
|
94
|
+
class Hash
|
95
|
+
# A hash is blank if it's empty:
|
96
|
+
#
|
97
|
+
# {}.blank? # => true
|
98
|
+
# { key: 'value' }.blank? # => false
|
99
|
+
#
|
100
|
+
# @return [true, false]
|
101
|
+
alias_method :blank?, :empty?
|
102
|
+
end
|
103
|
+
|
104
|
+
class String
|
105
|
+
BLANK_REGEXP = /\A[[:space:]]*\z/
|
106
|
+
|
107
|
+
# A string is blank if it's empty or contains whitespaces only:
|
108
|
+
#
|
109
|
+
# ''.blank? # => true
|
110
|
+
# ' '.blank? # => true
|
111
|
+
# "\t\n\r".blank? # => true
|
112
|
+
# ' blah '.blank? # => false
|
113
|
+
#
|
114
|
+
# Unicode whitespace is supported:
|
115
|
+
#
|
116
|
+
# "\u00a0".blank? # => true
|
117
|
+
#
|
118
|
+
# @return [true, false]
|
119
|
+
def blank?
|
120
|
+
BLANK_REGEXP === self
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
class Numeric #:nodoc:
|
125
|
+
# No number is blank:
|
126
|
+
#
|
127
|
+
# 1.blank? # => false
|
128
|
+
# 0.blank? # => false
|
129
|
+
#
|
130
|
+
# @return [false]
|
131
|
+
def blank?
|
132
|
+
false
|
133
|
+
end
|
134
|
+
end
|
135
|
+
# rubocop:enable all
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'key_flatten'
|
4
|
+
|
5
|
+
# rubocop:disable all
|
6
|
+
module Twm
|
7
|
+
class << self
|
8
|
+
#
|
9
|
+
# orig: local docs
|
10
|
+
# left: generate docs
|
11
|
+
# right: local src files
|
12
|
+
#
|
13
|
+
# condition: merge right into left
|
14
|
+
def yaml_merge(left, orig, right)
|
15
|
+
flat_orig = KeyFlatten.key_flatten(orig || {}).to_h
|
16
|
+
flat_left = KeyFlatten.key_flatten(left || {}).to_h
|
17
|
+
flat_right = KeyFlatten.key_flatten(right || {}).to_h
|
18
|
+
|
19
|
+
all_keys = (flat_left.keys + flat_orig.keys + flat_right.keys).uniq
|
20
|
+
|
21
|
+
twm = all_keys.each_with_object({}) do |key, result|
|
22
|
+
r = three_equal?(flat_left[key], flat_orig[key], flat_right[key])
|
23
|
+
|
24
|
+
if r[:left_orig] && r[:orig_right] && r[:left_right]
|
25
|
+
# no change
|
26
|
+
result[key] = flat_orig[key]
|
27
|
+
elsif r[:left_orig] && !r[:orig_right] && !r[:left_right]
|
28
|
+
# edited
|
29
|
+
result[key] = flat_right[key]
|
30
|
+
elsif !r[:left_orig] && r[:orig_right] && !r[:left_right]
|
31
|
+
# generate
|
32
|
+
result[key] = flat_left[key]
|
33
|
+
elsif !r[:left_orig] && !r[:orig_right] && r[:left_right]
|
34
|
+
# edited
|
35
|
+
result[key] = flat_right[key]
|
36
|
+
elsif !r[:left_orig] && !r[:orig_right] && !r[:left_right]
|
37
|
+
# conflict => prioritize edited
|
38
|
+
result[key] = flat_right[key]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
twm = twm.delete_if { |_k, v| v.nil? }
|
43
|
+
KeyFlatten.key_unflatten(twm)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def three_equal?(left, orig, right)
|
49
|
+
if left == orig && orig == right
|
50
|
+
{
|
51
|
+
left_orig: true,
|
52
|
+
orig_right: true,
|
53
|
+
left_right: true
|
54
|
+
}
|
55
|
+
elsif left == orig && orig != right
|
56
|
+
{
|
57
|
+
left_orig: true,
|
58
|
+
orig_right: false,
|
59
|
+
left_right: false
|
60
|
+
}
|
61
|
+
elsif left != orig && orig == right
|
62
|
+
{
|
63
|
+
left_orig: false,
|
64
|
+
orig_right: true,
|
65
|
+
left_right: false
|
66
|
+
}
|
67
|
+
elsif left != orig && orig != right && left == right
|
68
|
+
{
|
69
|
+
left_orig: false,
|
70
|
+
orig_right: false,
|
71
|
+
left_right: true
|
72
|
+
}
|
73
|
+
elsif left != orig && orig != right && left != right
|
74
|
+
{
|
75
|
+
left_orig: false,
|
76
|
+
orig_right: false,
|
77
|
+
left_right: false
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
# rubocop:enable all
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
require 'r2-oas/schema/v3/builder'
|
5
|
+
|
6
|
+
module R2OAS
|
7
|
+
module Schema
|
8
|
+
class Builder
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
def_delegators :@builder, :build_docs, :oas_doc
|
12
|
+
|
13
|
+
def initialize(options = {})
|
14
|
+
case ::R2OAS.version
|
15
|
+
when :v3
|
16
|
+
@builder = V3::Builder.new(options)
|
17
|
+
else
|
18
|
+
raise NoImplementError, "Do not support version: #{::R2OAS.version}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/r2-oas/schema/editor.rb
CHANGED
@@ -5,7 +5,6 @@ require 'eventmachine'
|
|
5
5
|
require 'watir'
|
6
6
|
require 'tempfile'
|
7
7
|
require 'fileutils'
|
8
|
-
require 'shell'
|
9
8
|
require 'forwardable'
|
10
9
|
|
11
10
|
# Can't use ActiveSupport::Autroload
|
@@ -20,6 +19,7 @@ module R2OAS
|
|
20
19
|
extend Forwardable
|
21
20
|
|
22
21
|
TMP_FILE_NAME = 'edited_schema'
|
22
|
+
ALERT_TEXT = 'Would you like to convert your JSON into YAML?'
|
23
23
|
|
24
24
|
attr_accessor :edited_schema
|
25
25
|
|
@@ -27,6 +27,7 @@ module R2OAS
|
|
27
27
|
super(options)
|
28
28
|
@editor = swagger.editor
|
29
29
|
@before_schema_data = before_schema_data
|
30
|
+
@schema_doc_from_local = YAML.load_file(doc_save_file_path).to_yaml
|
30
31
|
end
|
31
32
|
|
32
33
|
def start
|
@@ -71,15 +72,34 @@ module R2OAS
|
|
71
72
|
analyzer.analyze_docs
|
72
73
|
end
|
73
74
|
|
75
|
+
# MEMO
|
76
|
+
# TargetRubyVersion is 2.7 and there is a warning
|
77
|
+
# Because it is necessary to support from ruby2.3 series where begin cannot be omitted
|
78
|
+
# rubocop:disable Style/RedundantBegin
|
74
79
|
def ensure_save_tmp_schema_file
|
75
80
|
EM.add_periodic_timer(interval_to_save_edited_tmp_schema) do
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
81
|
+
m = Mutex.new
|
82
|
+
return nil unless @browser.exists?
|
83
|
+
|
84
|
+
m.synchronize do
|
85
|
+
begin
|
86
|
+
save_after_fetch_local_strage
|
87
|
+
rescue Selenium::WebDriver::Error::UnexpectedAlertOpenError
|
88
|
+
alert = @browser.driver.switch_to.alert
|
89
|
+
if alert.text.eql?(ALERT_TEXT)
|
90
|
+
alert.accept && save_after_fetch_local_strage
|
91
|
+
end
|
92
|
+
end
|
80
93
|
end
|
81
94
|
end
|
82
95
|
end
|
96
|
+
# rubocop:enable Style/RedundantBegin
|
97
|
+
|
98
|
+
def save_after_fetch_local_strage
|
99
|
+
@after_schema_data = @browser.driver.local_storage[storage_key] || @after_schema_data
|
100
|
+
save_edited_schema
|
101
|
+
puts "\nwait for signal trap ..."
|
102
|
+
end
|
83
103
|
|
84
104
|
def fetch_edited_schema_from_browser
|
85
105
|
@after_schema_data = @browser.driver.local_storage[storage_key] if @browser.exists?
|
@@ -94,8 +114,7 @@ module R2OAS
|
|
94
114
|
@browser ||= Watir::Browser.new(:chrome, capabilities)
|
95
115
|
@browser.goto(url)
|
96
116
|
if wait_for_loaded
|
97
|
-
|
98
|
-
@browser.driver.local_storage[storage_key] = schema_doc_from_local.to_yaml
|
117
|
+
@browser.driver.local_storage[storage_key] = @schema_doc_from_local
|
99
118
|
@browser.refresh
|
100
119
|
end
|
101
120
|
end
|