r2-oas 0.3.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +55 -1
- data/GEMSPEC.md +2 -2
- data/README.ja.md +73 -43
- data/README.md +75 -39
- data/lib/r2-oas.rb +4 -5
- data/lib/r2-oas/app_configuration.rb +17 -5
- data/lib/r2-oas/app_configuration/deprecation.rb +28 -0
- data/lib/r2-oas/configuration.rb +57 -11
- data/lib/r2-oas/configuration/paths_config.rb +6 -3
- data/lib/r2-oas/deploy/client.rb +1 -1
- data/lib/r2-oas/errors.rb +5 -0
- data/lib/r2-oas/helpers/file_helper.rb +68 -0
- data/lib/r2-oas/hooks/hook.rb +7 -5
- data/lib/r2-oas/lib/core_ext/all.rb +5 -0
- data/lib/r2-oas/lib/core_ext/string/filters.rb +29 -0
- data/lib/r2-oas/plugin/base.rb +44 -0
- data/lib/r2-oas/plugin/executor.rb +148 -0
- data/lib/r2-oas/plugin/hookable.rb +47 -0
- data/lib/r2-oas/plugin/public.rb +3 -0
- data/lib/r2-oas/plugin/transform/transform.rb +10 -0
- data/lib/r2-oas/plugin/transform/v3/transform.rb +20 -0
- data/lib/r2-oas/plugin/transform/v3/visitable.rb +37 -0
- data/lib/r2-oas/public.rb +3 -0
- data/lib/r2-oas/schema/base.rb +1 -1
- data/lib/r2-oas/schema/builder.rb +1 -1
- data/lib/r2-oas/schema/editor.rb +9 -2
- data/lib/r2-oas/schema/monitor.rb +1 -1
- data/lib/r2-oas/schema/ui.rb +1 -1
- data/lib/r2-oas/schema/v3/analyzer/path_analyzer.rb +1 -1
- data/lib/r2-oas/schema/v3/builder.rb +1 -1
- data/lib/r2-oas/schema/v3/builder/base_builder.rb +14 -2
- data/lib/r2-oas/schema/v3/builder/doc_builder.rb +10 -2
- data/lib/r2-oas/schema/v3/generator/base_generator.rb +7 -2
- data/lib/r2-oas/schema/v3/generator/doc_generator.rb +1 -1
- data/lib/r2-oas/schema/v3/manager/file/include_ref_base_file_manager.rb +3 -2
- data/lib/r2-oas/schema/v3/object/from_files/base_object.rb +62 -0
- data/lib/r2-oas/schema/v3/object/from_files/components/request_body_object.rb +103 -0
- data/lib/r2-oas/schema/v3/object/from_files/components/schema_object.rb +102 -0
- data/lib/r2-oas/schema/v3/object/from_files/components_object.rb +46 -0
- data/lib/r2-oas/schema/v3/object/from_files/external_document_object.rb +23 -0
- data/lib/r2-oas/schema/v3/object/from_files/info_object.rb +23 -0
- data/lib/r2-oas/schema/v3/object/from_files/openapi_object.rb +61 -0
- data/lib/r2-oas/schema/v3/object/from_files/path_item_object.rb +110 -0
- data/lib/r2-oas/schema/v3/object/from_files/paths_object.rb +33 -0
- data/lib/r2-oas/schema/v3/object/from_files/utils/all.rb +4 -0
- data/lib/r2-oas/schema/v3/object/from_files/utils/deep_methods.rb +27 -0
- data/lib/r2-oas/schema/v3/object/from_files/utils/refs.rb +151 -0
- data/lib/r2-oas/schema/v3/object/{public.rb → from_routes/all.rb} +0 -0
- data/lib/r2-oas/schema/v3/object/from_routes/base_object.rb +41 -0
- data/lib/r2-oas/schema/v3/object/{components → from_routes/components}/request_body_object.rb +19 -28
- data/lib/r2-oas/schema/v3/object/{components → from_routes/components}/schema_object.rb +12 -16
- data/lib/r2-oas/schema/v3/object/{components_object.rb → from_routes/components_object.rb} +19 -13
- data/lib/r2-oas/schema/v3/object/{external_document_object.rb → from_routes/external_document_object.rb} +9 -2
- data/lib/r2-oas/schema/v3/object/{info_object.rb → from_routes/info_object.rb} +9 -2
- data/lib/r2-oas/schema/v3/object/{openapi_object.rb → from_routes/openapi_object.rb} +16 -11
- data/lib/r2-oas/schema/v3/object/{path_item_object.rb → from_routes/path_item_object.rb} +8 -8
- data/lib/r2-oas/schema/v3/object/{paths_object.rb → from_routes/paths_object.rb} +13 -30
- data/lib/r2-oas/schema/v3/object/{server_object.rb → from_routes/server_object.rb} +0 -0
- data/lib/r2-oas/schema/v3/object/{tag_object.rb → from_routes/tag_object.rb} +2 -1
- data/lib/r2-oas/schema/v3/object/store.rb +54 -0
- data/lib/r2-oas/shared/all.rb +1 -0
- data/lib/r2-oas/shared/callable.rb +17 -0
- data/lib/r2-oas/store.rb +20 -16
- data/lib/r2-oas/support/deprecation.rb +26 -0
- data/lib/r2-oas/support/deprecation/behavior.rb +21 -0
- data/lib/r2-oas/support/deprecation/instance_delegator.rb +42 -0
- data/lib/r2-oas/support/deprecation/reporting.rb +91 -0
- data/lib/r2-oas/task.rb +1 -2
- data/lib/r2-oas/task_logging.rb +3 -7
- data/lib/r2-oas/tasks/common.rake +1 -2
- data/lib/r2-oas/tasks/main.rake +59 -9
- data/lib/r2-oas/version.rb +1 -1
- data/r2-oas.gemspec +2 -7
- metadata +55 -69
- data/.gitignore +0 -16
- data/.rspec +0 -3
- data/.rubocop.yml +0 -10
- data/.rubocop_todo.yml +0 -291
- data/.travis.yml +0 -26
- data/Appraisals +0 -13
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -12
- data/Rakefile +0 -8
- data/lib/r2-oas/app_configuration/tool.rb +0 -31
- data/lib/r2-oas/app_configuration/tool/paths/stats.rb +0 -43
- data/lib/r2-oas/pluggable_configuration.rb +0 -33
- data/lib/r2-oas/plugins/schema/v3/object/hookable_base_object.rb +0 -100
- data/lib/r2-oas/schema/v3/object/base_object.rb +0 -65
- data/lib/r2-oas/tasks/tool.rake +0 -83
- data/lib/r2-oas/tool/paths/ls.rb +0 -15
- data/lib/r2-oas/tool/paths/stats.rb +0 -84
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
require 'r2-oas/plugin/executor'
|
5
|
+
|
6
|
+
module R2OAS
|
7
|
+
module Schema
|
8
|
+
module V3
|
9
|
+
class BaseObject
|
10
|
+
extend Forwardable
|
11
|
+
|
12
|
+
def_delegators :@plugin_executor, :execute_transform_plugins
|
13
|
+
|
14
|
+
def initialize(opts = {})
|
15
|
+
AppConfiguration::VALID_OPTIONS_KEYS.each do |key|
|
16
|
+
send("#{key}=", app_configuration_options[key])
|
17
|
+
end
|
18
|
+
|
19
|
+
@opts = opts
|
20
|
+
@plugin_executor = ::R2OAS::Plugin::Executor.new(@plugins, opts)
|
21
|
+
end
|
22
|
+
|
23
|
+
def doc
|
24
|
+
@doc ||= {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_doc
|
28
|
+
raise 'Implement Inherit Class'
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def app_configuration_options
|
34
|
+
R2OAS.app_configuration_options
|
35
|
+
end
|
36
|
+
|
37
|
+
attr_accessor *AppConfiguration::VALID_OPTIONS_KEYS
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/r2-oas/schema/v3/object/{components → from_routes/components}/request_body_object.rb
RENAMED
@@ -1,28 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'r2-oas/
|
3
|
+
require 'r2-oas/schema/v3/object/from_routes/base_object'
|
4
4
|
require 'r2-oas/schema/v3/manager/file/components_file_manager'
|
5
|
+
require_relative 'schema_object'
|
5
6
|
|
6
7
|
module R2OAS
|
7
8
|
module Schema
|
8
9
|
module V3
|
9
10
|
module Components
|
10
|
-
class RequestBodyObject < R2OAS::
|
11
|
-
def initialize(route_data, path)
|
12
|
-
super()
|
11
|
+
class RequestBodyObject < R2OAS::Schema::V3::BaseObject
|
12
|
+
def initialize(route_data, path, opts = {})
|
13
|
+
super(opts)
|
13
14
|
@path_comp = Routing::PathComponent.new(path)
|
14
15
|
@path = @path_comp.symbol_to_brace
|
15
16
|
@route_data = route_data
|
16
17
|
@verb = route_data[:verb]
|
17
18
|
@tag_name = route_data[:tag_name]
|
18
19
|
@schema_name = route_data[:schema_name]
|
20
|
+
# MEMO:
|
21
|
+
# Allow primitive types that cannot be passed by reference to be passed by reference
|
22
|
+
# This is Compromise
|
23
|
+
@ref = { schema_name: @schema_name, tag_name: @tag_name, verb: @verb }
|
19
24
|
end
|
20
25
|
|
21
26
|
def to_doc
|
22
|
-
execute_before_create(@schema_name)
|
23
27
|
create_doc do
|
24
28
|
child_file_manager = ComponentsFileManager.new("#/components/schemas/#{_components_schema_name}", :ref)
|
25
|
-
schema_object =
|
29
|
+
schema_object = Components::SchemaObject.new(@route_data, @path, @opts)
|
26
30
|
|
27
31
|
unless child_file_manager.skip_save?
|
28
32
|
result = {
|
@@ -41,10 +45,16 @@ module R2OAS
|
|
41
45
|
)
|
42
46
|
end
|
43
47
|
end
|
44
|
-
execute_after_create(@schema_name)
|
45
48
|
doc
|
46
49
|
end
|
47
50
|
|
51
|
+
def generate?
|
52
|
+
file_manager = ComponentsFileManager.new("#/components/schemas/#{_components_schema_name}", :ref)
|
53
|
+
(@verb.in? http_methods_when_generate_request_body) && !file_manager.skip_save?
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
48
58
|
def create_doc
|
49
59
|
file_manager = ComponentsFileManager.new("#/components/schemas/#{_components_schema_name}", :ref)
|
50
60
|
doc.deep_merge!(
|
@@ -59,31 +69,12 @@ module R2OAS
|
|
59
69
|
yield if block_given?
|
60
70
|
end
|
61
71
|
|
62
|
-
# MEMO:
|
63
|
-
# please override in inherited class.
|
64
|
-
def components_schema_name(_doc, _path_component, _tag_name, _verb, schema_name)
|
65
|
-
schema_name
|
66
|
-
end
|
67
|
-
|
68
|
-
# MEMO:
|
69
|
-
# please override in inherited class.
|
70
|
-
def components_request_body_name(_doc, _path_component, _tag_name, _verb, schema_name)
|
71
|
-
schema_name
|
72
|
-
end
|
73
|
-
|
74
|
-
def generate?
|
75
|
-
file_manager = ComponentsFileManager.new("#/components/schemas/#{_components_schema_name}", :ref)
|
76
|
-
(@verb.in? http_methods_when_generate_request_body) && !file_manager.skip_save?
|
77
|
-
end
|
78
|
-
|
79
|
-
private
|
80
|
-
|
81
72
|
def _components_schema_name
|
82
|
-
|
73
|
+
@schema_name
|
83
74
|
end
|
84
75
|
|
85
76
|
def _components_request_body_name
|
86
|
-
|
77
|
+
@schema_name
|
87
78
|
end
|
88
79
|
end
|
89
80
|
end
|
@@ -1,29 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'r2-oas/
|
3
|
+
require 'r2-oas/schema/v3/object/from_routes/base_object'
|
4
4
|
|
5
5
|
module R2OAS
|
6
6
|
module Schema
|
7
7
|
module V3
|
8
8
|
module Components
|
9
|
-
class SchemaObject < R2OAS::
|
10
|
-
def initialize(route_data, path)
|
11
|
-
super()
|
9
|
+
class SchemaObject < R2OAS::Schema::V3::BaseObject
|
10
|
+
def initialize(route_data, path, opts = {})
|
11
|
+
super(opts)
|
12
12
|
@path_comp = Routing::PathComponent.new(path)
|
13
13
|
@path = @path_comp.symbol_to_brace
|
14
14
|
@route_data = route_data
|
15
15
|
@verb = route_data[:verb]
|
16
16
|
@tag_name = route_data[:tag_name]
|
17
17
|
@schema_name = route_data[:schema_name]
|
18
|
+
# MEMO:
|
19
|
+
# Allow primitive types that cannot be passed by reference to be passed by reference
|
20
|
+
# This is Compromise
|
21
|
+
@ref = { schema_name: @schema_name, tag_name: @tag_name, verb: @verb }
|
18
22
|
end
|
19
23
|
|
20
24
|
def to_doc
|
21
|
-
execute_before_create(@schema_name)
|
22
25
|
create_doc
|
23
|
-
execute_after_create(@schema_name)
|
24
26
|
doc
|
25
27
|
end
|
26
28
|
|
29
|
+
private
|
30
|
+
|
27
31
|
def create_doc
|
28
32
|
result = {
|
29
33
|
'type' => 'object',
|
@@ -37,16 +41,8 @@ module R2OAS
|
|
37
41
|
doc.merge!(result)
|
38
42
|
end
|
39
43
|
|
40
|
-
|
41
|
-
|
42
|
-
def components_schema_name(_doc, _path_component, _tag_name, _verb, _http_status, schema_name)
|
43
|
-
schema_name
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def _components_schema_name(http_status)
|
49
|
-
components_schema_name(doc, @path_comp, @tag_name, @verb, http_status, @schema_name)
|
44
|
+
def _components_schema_name(_http_status)
|
45
|
+
@schema_name
|
50
46
|
end
|
51
47
|
end
|
52
48
|
end
|
@@ -1,18 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'base_object'
|
4
4
|
require_relative 'components/schema_object'
|
5
5
|
require_relative 'components/request_body_object'
|
6
|
+
require_relative 'path_item_object'
|
6
7
|
|
7
8
|
module R2OAS
|
8
9
|
module Schema
|
9
10
|
module V3
|
10
|
-
class ComponentsObject <
|
11
|
-
def initialize(routes_data)
|
12
|
-
super()
|
11
|
+
class ComponentsObject < BaseObject
|
12
|
+
def initialize(routes_data, opts = {})
|
13
|
+
super(opts)
|
13
14
|
@routes_data = routes_data
|
14
15
|
end
|
15
16
|
|
17
|
+
def to_doc
|
18
|
+
create_doc
|
19
|
+
doc
|
20
|
+
end
|
21
|
+
|
16
22
|
def create_doc
|
17
23
|
create_doc_for_components_schemas!
|
18
24
|
create_doc_for_components_request_bodies!
|
@@ -24,14 +30,14 @@ module R2OAS
|
|
24
30
|
result = components_schema_docs.each_with_object({}) do |(schema_name, components_schema_doc), docs|
|
25
31
|
docs[schema_name] = components_schema_doc
|
26
32
|
end
|
27
|
-
doc.merge!('schemas' => result)
|
33
|
+
doc.merge!({ 'schemas' => result })
|
28
34
|
end
|
29
35
|
|
30
36
|
def create_doc_for_components_request_bodies!
|
31
37
|
result = components_request_body_docs.each_with_object({}) do |(schema_name, components_request_body_doc), docs|
|
32
38
|
docs[schema_name] = components_request_body_doc
|
33
39
|
end
|
34
|
-
doc.merge!('requestBodies' => result)
|
40
|
+
doc.merge!({ 'requestBodies' => result })
|
35
41
|
end
|
36
42
|
|
37
43
|
# e.x.)
|
@@ -40,12 +46,12 @@ module R2OAS
|
|
40
46
|
# ]
|
41
47
|
def components_schema_docs
|
42
48
|
@routes_data.each_with_object({}) do |(route_el), data|
|
43
|
-
path
|
44
|
-
route_data
|
49
|
+
path = route_el[:path]
|
50
|
+
route_data = route_el[:data]
|
45
51
|
|
46
|
-
path_item_object =
|
52
|
+
path_item_object = PathItemObject.new(route_data, path, @opts)
|
47
53
|
path_item_object.http_statuses.each do |http_status|
|
48
|
-
components_schema_object =
|
54
|
+
components_schema_object = Components::SchemaObject.new(route_data, path, @opts)
|
49
55
|
components_schema_doc = components_schema_object.to_doc
|
50
56
|
schema_name = components_schema_object.send(:_components_schema_name, http_status)
|
51
57
|
|
@@ -60,10 +66,10 @@ module R2OAS
|
|
60
66
|
|
61
67
|
def components_request_body_docs
|
62
68
|
@routes_data.each_with_object({}) do |(route_el), data|
|
63
|
-
path
|
64
|
-
route_data
|
69
|
+
path = route_el[:path]
|
70
|
+
route_data = route_el[:data]
|
65
71
|
|
66
|
-
components_request_body_object =
|
72
|
+
components_request_body_object = Components::RequestBodyObject.new(route_data, path, @opts)
|
67
73
|
next unless components_request_body_object.generate?
|
68
74
|
|
69
75
|
components_request_body_doc = components_request_body_object.to_doc
|
@@ -1,11 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'base_object'
|
4
4
|
|
5
5
|
module R2OAS
|
6
6
|
module Schema
|
7
7
|
module V3
|
8
|
-
class ExternalDocumentObject <
|
8
|
+
class ExternalDocumentObject < BaseObject
|
9
|
+
def to_doc
|
10
|
+
create_doc
|
11
|
+
doc
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
9
16
|
def create_doc
|
10
17
|
result = {
|
11
18
|
'description' => '',
|
@@ -1,11 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'base_object'
|
4
4
|
|
5
5
|
module R2OAS
|
6
6
|
module Schema
|
7
7
|
module V3
|
8
|
-
class InfoObject <
|
8
|
+
class InfoObject < BaseObject
|
9
|
+
def to_doc
|
10
|
+
create_doc
|
11
|
+
doc
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
9
16
|
def create_doc
|
10
17
|
result = {
|
11
18
|
'title' => 'OAS API Document Title',
|
@@ -3,20 +3,24 @@
|
|
3
3
|
require_relative 'base_object'
|
4
4
|
require_relative 'tag_object'
|
5
5
|
require_relative 'server_object'
|
6
|
+
require_relative 'info_object'
|
7
|
+
require_relative 'external_document_object'
|
8
|
+
require_relative 'components_object'
|
9
|
+
require_relative 'paths_object'
|
6
10
|
|
7
11
|
module R2OAS
|
8
12
|
module Schema
|
9
13
|
module V3
|
10
14
|
class OpenapiObject < BaseObject
|
11
|
-
def initialize(routes_data, tags_data, schemas_data)
|
12
|
-
super()
|
13
|
-
@routes_data
|
14
|
-
@tags_data
|
15
|
+
def initialize(routes_data, tags_data, schemas_data, opts = {})
|
16
|
+
super(opts)
|
17
|
+
@routes_data = routes_data
|
18
|
+
@tags_data = tags_data
|
15
19
|
@schemas_data = schemas_data
|
16
20
|
end
|
17
21
|
|
18
22
|
def to_doc
|
19
|
-
{
|
23
|
+
result = {
|
20
24
|
'openapi' => '3.0.0',
|
21
25
|
'info' => info_doc,
|
22
26
|
'tags' => tags_doc,
|
@@ -25,32 +29,33 @@ module R2OAS
|
|
25
29
|
'servers' => servers_doc,
|
26
30
|
'components' => components_doc
|
27
31
|
}
|
32
|
+
doc.merge!(result)
|
28
33
|
end
|
29
34
|
|
30
35
|
private
|
31
36
|
|
32
37
|
def info_doc
|
33
|
-
|
38
|
+
InfoObject.new(@opts).to_doc
|
34
39
|
end
|
35
40
|
|
36
41
|
def tags_doc
|
37
|
-
TagObject.new(@tags_data).to_doc
|
42
|
+
TagObject.new(@tags_data, @opts).to_doc
|
38
43
|
end
|
39
44
|
|
40
45
|
def paths_doc
|
41
|
-
|
46
|
+
PathsObject.new(@routes_data, @opts).to_doc
|
42
47
|
end
|
43
48
|
|
44
49
|
def external_docs_doc
|
45
|
-
|
50
|
+
ExternalDocumentObject.new(@opts).to_doc
|
46
51
|
end
|
47
52
|
|
48
53
|
def servers_doc
|
49
|
-
ServerObject.new.to_doc
|
54
|
+
ServerObject.new(@opts).to_doc
|
50
55
|
end
|
51
56
|
|
52
57
|
def components_doc
|
53
|
-
|
58
|
+
ComponentsObject.new(@routes_data, @opts).to_doc
|
54
59
|
end
|
55
60
|
end
|
56
61
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'forwardable'
|
4
|
-
require 'r2-oas/plugins/schema/v3/object/hookable_base_object'
|
5
4
|
require 'r2-oas/routing/components/path_component'
|
5
|
+
require_relative 'base_object'
|
6
|
+
require_relative 'components/schema_object'
|
7
|
+
require_relative 'components/request_body_object'
|
6
8
|
|
7
9
|
module R2OAS
|
8
10
|
module Schema
|
9
11
|
module V3
|
10
|
-
class PathItemObject <
|
12
|
+
class PathItemObject < BaseObject
|
11
13
|
extend Forwardable
|
12
14
|
# reference
|
13
15
|
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#path-item-object
|
@@ -16,8 +18,8 @@ module R2OAS
|
|
16
18
|
|
17
19
|
def_delegators :@http_status_manager, :http_statuses
|
18
20
|
|
19
|
-
def initialize(route_data, path)
|
20
|
-
super()
|
21
|
+
def initialize(route_data, path, opts = {})
|
22
|
+
super(opts)
|
21
23
|
@path_comp = Routing::PathComponent.new(path)
|
22
24
|
@path = @path_comp.symbol_to_brace
|
23
25
|
@route_data = route_data
|
@@ -27,15 +29,13 @@ module R2OAS
|
|
27
29
|
@required_parameters = route_data[:required_parameters]
|
28
30
|
@format_name = create_format_name
|
29
31
|
@http_status_manager = HttpStatusManager.new(@path, @verb, http_statuses_when_http_method)
|
30
|
-
@components_schema_object =
|
31
|
-
@components_request_body_object =
|
32
|
+
@components_schema_object = Components::SchemaObject.new(route_data, path, opts)
|
33
|
+
@components_request_body_object = Components::RequestBodyObject.new(route_data, path, opts)
|
32
34
|
support_field_name? if route_data.key?(:verb)
|
33
35
|
end
|
34
36
|
|
35
37
|
def to_doc
|
36
|
-
execute_before_create(@path)
|
37
38
|
create_doc
|
38
|
-
execute_after_create(@path)
|
39
39
|
doc
|
40
40
|
end
|
41
41
|
|
@@ -1,22 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'r2-oas/
|
3
|
+
require 'r2-oas/routing/components/path_component'
|
4
|
+
require_relative 'base_object'
|
5
|
+
require_relative 'path_item_object'
|
4
6
|
|
5
7
|
module R2OAS
|
6
8
|
module Schema
|
7
9
|
module V3
|
8
|
-
class PathsObject <
|
9
|
-
def initialize(routes_data)
|
10
|
-
super()
|
10
|
+
class PathsObject < BaseObject
|
11
|
+
def initialize(routes_data, opts = {})
|
12
|
+
super(opts)
|
11
13
|
@routes_data = routes_data
|
12
|
-
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_doc
|
17
|
+
create_doc
|
18
|
+
doc
|
13
19
|
end
|
14
20
|
|
15
21
|
def create_doc
|
16
22
|
if unit_paths_file_path.present?
|
17
23
|
unit_paths_data = YAML.load_file(unit_paths_file_path)['paths']
|
18
24
|
result = unit_paths_data.each_with_object({}) do |(path, path_item_doc), docs|
|
19
|
-
docs[path] =
|
25
|
+
docs[path] = PathItemObject.new(path_item_doc, path, @opts).to_doc
|
20
26
|
end
|
21
27
|
else
|
22
28
|
result = path_item_docs.each_with_object({}) do |(path, path_item_doc), docs|
|
@@ -28,29 +34,6 @@ module R2OAS
|
|
28
34
|
|
29
35
|
private
|
30
36
|
|
31
|
-
def define_hookable_tmp_object_class
|
32
|
-
klass = Class.new(path_item_object_class) do |_c|
|
33
|
-
def initialize(data, path)
|
34
|
-
super
|
35
|
-
@data = data
|
36
|
-
@path = path
|
37
|
-
use_superclass_hook
|
38
|
-
end
|
39
|
-
|
40
|
-
def create_doc
|
41
|
-
doc.merge!(@data)
|
42
|
-
end
|
43
|
-
|
44
|
-
def to_doc
|
45
|
-
execute_before_create(@path)
|
46
|
-
create_doc
|
47
|
-
execute_after_create(@path)
|
48
|
-
doc
|
49
|
-
end
|
50
|
-
end
|
51
|
-
Object.const_set(:HookableTmpObjectClass, klass) unless defined?(HookableTmpObjectClass)
|
52
|
-
end
|
53
|
-
|
54
37
|
def path_item_docs
|
55
38
|
# e.x.)
|
56
39
|
# [
|
@@ -60,7 +43,7 @@ module R2OAS
|
|
60
43
|
path = route_el[:path]
|
61
44
|
route_data = route_el[:data]
|
62
45
|
|
63
|
-
path_item_doc =
|
46
|
+
path_item_doc = PathItemObject.new(route_data, path, @opts).to_doc
|
64
47
|
if data[path].present?
|
65
48
|
data[path].merge!(path_item_doc)
|
66
49
|
else
|