committee 1.15.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +5 -5
  2. data/bin/committee-stub +11 -38
  3. data/lib/committee/bin/committee_stub.rb +67 -0
  4. data/lib/committee/drivers/driver.rb +47 -0
  5. data/lib/committee/drivers/hyper_schema/driver.rb +105 -0
  6. data/lib/committee/drivers/hyper_schema/link.rb +68 -0
  7. data/lib/committee/drivers/hyper_schema/schema.rb +22 -0
  8. data/lib/committee/drivers/hyper_schema.rb +12 -0
  9. data/lib/committee/drivers/open_api_2/driver.rb +252 -0
  10. data/lib/committee/drivers/open_api_2/header_schema_builder.rb +33 -0
  11. data/lib/committee/drivers/open_api_2/link.rb +36 -0
  12. data/lib/committee/drivers/open_api_2/parameter_schema_builder.rb +83 -0
  13. data/lib/committee/drivers/open_api_2/schema.rb +26 -0
  14. data/lib/committee/drivers/open_api_2/schema_builder.rb +33 -0
  15. data/lib/committee/drivers/open_api_2.rb +13 -0
  16. data/lib/committee/drivers/open_api_3/driver.rb +51 -0
  17. data/lib/committee/drivers/open_api_3/schema.rb +41 -0
  18. data/lib/committee/drivers/open_api_3.rb +11 -0
  19. data/lib/committee/drivers/schema.rb +23 -0
  20. data/lib/committee/drivers.rb +84 -0
  21. data/lib/committee/errors.rb +17 -0
  22. data/lib/committee/middleware/base.rb +46 -29
  23. data/lib/committee/middleware/request_validation.rb +31 -49
  24. data/lib/committee/middleware/response_validation.rb +48 -25
  25. data/lib/committee/middleware/stub.rb +62 -37
  26. data/lib/committee/middleware.rb +11 -0
  27. data/lib/committee/request_unpacker.rb +58 -50
  28. data/lib/committee/schema_validator/hyper_schema/parameter_coercer.rb +79 -0
  29. data/lib/committee/schema_validator/hyper_schema/request_validator.rb +55 -0
  30. data/lib/committee/schema_validator/hyper_schema/response_generator.rb +102 -0
  31. data/lib/committee/schema_validator/hyper_schema/response_validator.rb +89 -0
  32. data/lib/committee/schema_validator/hyper_schema/router.rb +46 -0
  33. data/lib/committee/schema_validator/hyper_schema/string_params_coercer.rb +105 -0
  34. data/lib/committee/schema_validator/hyper_schema.rb +119 -0
  35. data/lib/committee/schema_validator/open_api_3/operation_wrapper.rb +139 -0
  36. data/lib/committee/schema_validator/open_api_3/request_validator.rb +52 -0
  37. data/lib/committee/schema_validator/open_api_3/response_validator.rb +29 -0
  38. data/lib/committee/schema_validator/open_api_3/router.rb +45 -0
  39. data/lib/committee/schema_validator/open_api_3.rb +120 -0
  40. data/lib/committee/schema_validator/option.rb +60 -0
  41. data/lib/committee/schema_validator.rb +23 -0
  42. data/lib/committee/test/methods.rb +68 -38
  43. data/lib/committee/test/schema_coverage.rb +101 -0
  44. data/lib/committee/utils.rb +28 -0
  45. data/lib/committee/validation_error.rb +5 -2
  46. data/lib/committee/version.rb +5 -0
  47. data/lib/committee.rb +31 -18
  48. data/test/bin/committee_stub_test.rb +57 -0
  49. data/test/bin_test.rb +25 -0
  50. data/test/committee_test.rb +77 -0
  51. data/test/drivers/hyper_schema/driver_test.rb +49 -0
  52. data/test/drivers/hyper_schema/link_test.rb +56 -0
  53. data/test/drivers/open_api_2/driver_test.rb +156 -0
  54. data/test/drivers/open_api_2/header_schema_builder_test.rb +26 -0
  55. data/test/drivers/open_api_2/link_test.rb +52 -0
  56. data/test/drivers/open_api_2/parameter_schema_builder_test.rb +195 -0
  57. data/test/drivers/open_api_3/driver_test.rb +84 -0
  58. data/test/drivers_test.rb +154 -0
  59. data/test/middleware/base_test.rb +96 -7
  60. data/test/middleware/request_validation_open_api_3_test.rb +626 -0
  61. data/test/middleware/request_validation_test.rb +423 -32
  62. data/test/middleware/response_validation_open_api_3_test.rb +291 -0
  63. data/test/middleware/response_validation_test.rb +125 -23
  64. data/test/middleware/stub_test.rb +81 -20
  65. data/test/request_unpacker_test.rb +126 -52
  66. data/test/schema_validator/hyper_schema/parameter_coercer_test.rb +111 -0
  67. data/test/schema_validator/hyper_schema/request_validator_test.rb +151 -0
  68. data/test/schema_validator/hyper_schema/response_generator_test.rb +142 -0
  69. data/test/{response_validator_test.rb → schema_validator/hyper_schema/response_validator_test.rb} +43 -6
  70. data/test/schema_validator/hyper_schema/router_test.rb +88 -0
  71. data/test/schema_validator/hyper_schema/string_params_coercer_test.rb +137 -0
  72. data/test/schema_validator/open_api_3/operation_wrapper_test.rb +218 -0
  73. data/test/schema_validator/open_api_3/request_validator_test.rb +110 -0
  74. data/test/schema_validator/open_api_3/response_validator_test.rb +92 -0
  75. data/test/test/methods_new_version_test.rb +97 -0
  76. data/test/test/methods_test.rb +334 -27
  77. data/test/test/schema_coverage_test.rb +216 -0
  78. data/test/test_helper.rb +108 -1
  79. data/test/validation_error_test.rb +3 -1
  80. metadata +190 -27
  81. data/lib/committee/query_params_coercer.rb +0 -45
  82. data/lib/committee/request_validator.rb +0 -44
  83. data/lib/committee/response_generator.rb +0 -35
  84. data/lib/committee/response_validator.rb +0 -59
  85. data/lib/committee/router.rb +0 -62
  86. data/test/query_params_coercer_test.rb +0 -70
  87. data/test/request_validator_test.rb +0 -103
  88. data/test/response_generator_test.rb +0 -61
  89. data/test/router_test.rb +0 -38
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ describe Committee::Drivers::HyperSchema::Link do
6
+ before do
7
+ @hyper_schema_link = JsonSchema::Schema::Link.new
8
+ @hyper_schema_link.enc_type = "application/x-www-form-urlencoded"
9
+ @hyper_schema_link.href = "/apps"
10
+ @hyper_schema_link.media_type = "application/json"
11
+ @hyper_schema_link.method = "GET"
12
+ @hyper_schema_link.parent = { "title" => "parent" }
13
+ @hyper_schema_link.rel = "instances"
14
+ @hyper_schema_link.schema = { "title" => "input" }
15
+ @hyper_schema_link.target_schema = { "title" => "target" }
16
+
17
+ @link = Committee::Drivers::HyperSchema::Link.new(@hyper_schema_link)
18
+ end
19
+
20
+ it "proxies #enc_type" do
21
+ assert_equal "application/x-www-form-urlencoded", @link.enc_type
22
+ end
23
+
24
+ it "proxies #href" do
25
+ assert_equal "/apps", @link.href
26
+ end
27
+
28
+ it "proxies #media_type" do
29
+ assert_equal "application/json", @link.media_type
30
+ end
31
+
32
+ it "proxies #method" do
33
+ assert_equal "GET", @link.method
34
+ end
35
+
36
+ it "proxies #rel" do
37
+ assert_equal "instances", @link.rel
38
+ end
39
+
40
+ it "proxies #schema" do
41
+ assert_equal @hyper_schema_link.schema, @link.schema
42
+ end
43
+
44
+ it "generates 200 #status_success for non-create" do
45
+ assert_equal 200, @link.status_success
46
+ end
47
+
48
+ it "generates 201 #status_success for create" do
49
+ @hyper_schema_link.rel = "create"
50
+ assert_equal 201, @link.status_success
51
+ end
52
+
53
+ it "proxies #target_schema" do
54
+ assert_equal @hyper_schema_link.target_schema, @link.target_schema
55
+ end
56
+ end
@@ -0,0 +1,156 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ describe Committee::Drivers::OpenAPI2::Driver do
6
+ before do
7
+ @driver = Committee::Drivers::OpenAPI2::Driver.new
8
+ end
9
+
10
+ it "has a name" do
11
+ assert_equal :open_api_2, @driver.name
12
+ end
13
+
14
+ it "has a schema class" do
15
+ assert_equal Committee::Drivers::OpenAPI2::Schema, @driver.schema_class
16
+ end
17
+
18
+ it "parses an OpenAPI 2 spec" do
19
+ schema = @driver.parse(open_api_2_data)
20
+ assert_kind_of Committee::Drivers::OpenAPI2::Schema, schema
21
+ assert_kind_of JsonSchema::Schema, schema.definitions
22
+ assert_equal @driver, schema.driver
23
+
24
+ assert_kind_of Hash, schema.routes
25
+ refute schema.routes.empty?
26
+ assert(schema.routes.keys.all? { |m|
27
+ ["DELETE", "GET", "PATCH", "POST", "PUT"].include?(m)
28
+ })
29
+
30
+ schema.routes.each do |(_, method_routes)|
31
+ method_routes.each do |regex, link|
32
+ assert_kind_of Regexp, regex
33
+ assert_kind_of Committee::Drivers::OpenAPI2::Link, link
34
+
35
+ # verify that we've correct generated a parameters schema for each link
36
+ if link.target_schema
37
+ assert_kind_of JsonSchema::Schema, link.schema if link.schema
38
+ end
39
+
40
+ if link.target_schema
41
+ assert_kind_of JsonSchema::Schema, link.target_schema
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ it "names capture groups into href regexes" do
48
+ schema = @driver.parse(open_api_2_data)
49
+ assert_equal %r{^\/api\/pets\/(?<id>[^\/]+)$}.inspect,
50
+ schema.routes["DELETE"][0][0].inspect
51
+ end
52
+
53
+ it "prefers a 200 response first" do
54
+ schema_data = schema_data_with_responses({
55
+ '201' => { 'schema' => { 'description' => '201 response' } },
56
+ '200' => { 'schema' => { 'description' => '200 response' } },
57
+ })
58
+
59
+ schema = @driver.parse(schema_data)
60
+ link = schema.routes['GET'][0][1]
61
+ assert_equal 200, link.status_success
62
+ assert_equal({ 'description' => '200 response' }, link.target_schema.data)
63
+ end
64
+
65
+ it "prefers a 201 response next" do
66
+ schema_data = schema_data_with_responses({
67
+ '302' => { 'schema' => { 'description' => '302 response' } },
68
+ '201' => { 'schema' => { 'description' => '201 response' } },
69
+ })
70
+
71
+ schema = @driver.parse(schema_data)
72
+ link = schema.routes['GET'][0][1]
73
+ assert_equal 201, link.status_success
74
+ assert_equal({ 'description' => '201 response' }, link.target_schema.data)
75
+ end
76
+
77
+ it "prefers any three-digit response next" do
78
+ schema_data = schema_data_with_responses({
79
+ 'default' => { 'schema' => { 'description' => 'default response' } },
80
+ '302' => { 'schema' => { 'description' => '302 response' } },
81
+ })
82
+
83
+ schema = @driver.parse(schema_data)
84
+ link = schema.routes['GET'][0][1]
85
+ assert_equal 302, link.status_success
86
+ assert_equal({ 'description' => '302 response' }, link.target_schema.data)
87
+ end
88
+
89
+ it "prefers any numeric three-digit response next" do
90
+ schema_data = schema_data_with_responses({
91
+ 'default' => { 'schema' => { 'description' => 'default response' } },
92
+ 302 => { 'schema' => { 'description' => '302 response' } },
93
+ })
94
+
95
+ schema = @driver.parse(schema_data)
96
+ link = schema.routes['GET'][0][1]
97
+ assert_equal 302, link.status_success
98
+ assert_equal({ 'description' => '302 response' }, link.target_schema.data)
99
+ end
100
+
101
+ it "falls back to no response" do
102
+ schema_data = schema_data_with_responses({})
103
+
104
+ schema = @driver.parse(schema_data)
105
+ link = schema.routes['GET'][0][1]
106
+ assert_nil link.status_success
107
+ assert_nil link.target_schema
108
+ end
109
+
110
+ it "refuses to parse other version of OpenAPI" do
111
+ data = open_api_2_data
112
+ data['swagger'] = '3.0'
113
+ e = assert_raises(ArgumentError) do
114
+ @driver.parse(data)
115
+ end
116
+ assert_equal "Committee: driver requires OpenAPI 2.0.", e.message
117
+ end
118
+
119
+ it "refuses to parse a spec without mandatory fields" do
120
+ data = open_api_2_data
121
+ data['definitions'] = nil
122
+ e = assert_raises(ArgumentError) do
123
+ @driver.parse(data)
124
+ end
125
+ assert_equal "Committee: no definitions section in spec data.", e.message
126
+ end
127
+
128
+ it "defaults to coercing form parameters" do
129
+ assert_equal true, @driver.default_coerce_form_params
130
+ end
131
+
132
+ it "defaults to path parameters" do
133
+ assert_equal true, @driver.default_path_params
134
+ end
135
+
136
+ it "defaults to query parameters" do
137
+ assert_equal true, @driver.default_query_params
138
+ end
139
+
140
+ def schema_data_with_responses(response_data)
141
+ {
142
+ 'swagger' => '2.0',
143
+ 'consumes' => ['application/json'],
144
+ 'produces' => ['application/json'],
145
+ 'paths' => {
146
+ '/foos' => {
147
+ 'get' => {
148
+ 'responses' => response_data,
149
+ },
150
+ },
151
+ },
152
+ 'definitions' => {},
153
+ }
154
+ end
155
+ end
156
+
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ describe Committee::Drivers::OpenAPI2::HeaderSchemaBuilder do
6
+ it "returns schema data for header" do
7
+ data = {
8
+ "parameters" => [
9
+ {
10
+ "name" => "AUTH_TOKEN",
11
+ "type" => "string",
12
+ "in" => "header",
13
+ }
14
+ ]
15
+ }
16
+ schema = call(data)
17
+
18
+ assert_equal ["string"], schema.properties["AUTH_TOKEN"].type
19
+ end
20
+
21
+ private
22
+
23
+ def call(data)
24
+ Committee::Drivers::OpenAPI2::HeaderSchemaBuilder.new(data).call
25
+ end
26
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ describe Committee::Drivers::OpenAPI2::Link do
6
+ before do
7
+ @link = Committee::Drivers::OpenAPI2::Link.new
8
+ @link.enc_type = "application/x-www-form-urlencoded"
9
+ @link.href = "/apps"
10
+ @link.media_type = "application/json"
11
+ @link.method = "GET"
12
+ @link.status_success = 200
13
+ @link.schema = { "title" => "input" }
14
+ @link.target_schema = { "title" => "target" }
15
+ end
16
+
17
+ it "uses set #enc_type" do
18
+ assert_equal "application/x-www-form-urlencoded", @link.enc_type
19
+ end
20
+
21
+ it "uses set #href" do
22
+ assert_equal "/apps", @link.href
23
+ end
24
+
25
+ it "uses set #media_type" do
26
+ assert_equal "application/json", @link.media_type
27
+ end
28
+
29
+ it "uses set #method" do
30
+ assert_equal "GET", @link.method
31
+ end
32
+
33
+ it "proxies #rel" do
34
+ e = assert_raises do
35
+ @link.rel
36
+ end
37
+ assert_equal "Committee: rel not implemented for OpenAPI", e.message
38
+ end
39
+
40
+ it "uses set #schema" do
41
+ assert_equal({ "title" => "input" }, @link.schema)
42
+ end
43
+
44
+ it "uses set #status_success" do
45
+ assert_equal 200, @link.status_success
46
+ end
47
+
48
+ it "uses set #target_schema" do
49
+ assert_equal({ "title" => "target" }, @link.target_schema)
50
+ end
51
+ end
52
+
@@ -0,0 +1,195 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ describe Committee::Drivers::OpenAPI2::ParameterSchemaBuilder do
6
+ before do
7
+ end
8
+
9
+ it "reflects a basic type into a schema" do
10
+ data = {
11
+ "parameters" => [
12
+ {
13
+ "name" => "limit",
14
+ "type" => "integer",
15
+ }
16
+ ]
17
+ }
18
+ schema, schema_data = call(data)
19
+
20
+ assert_nil schema_data
21
+ assert_equal ["limit"], schema.properties.keys
22
+ assert_equal [], schema.required
23
+ assert_equal ["integer"], schema.properties["limit"].type
24
+ assert_nil schema.properties["limit"].enum
25
+ assert_nil schema.properties["limit"].format
26
+ assert_nil schema.properties["limit"].pattern
27
+ assert_nil schema.properties["limit"].min_length
28
+ assert_nil schema.properties["limit"].max_length
29
+ assert_nil schema.properties["limit"].min_items
30
+ assert_nil schema.properties["limit"].max_items
31
+ assert_nil schema.properties["limit"].unique_items
32
+ assert_nil schema.properties["limit"].min
33
+ assert_nil schema.properties["limit"].min_exclusive
34
+ assert_nil schema.properties["limit"].max
35
+ assert_nil schema.properties["limit"].max_exclusive
36
+ assert_nil schema.properties["limit"].multiple_of
37
+ end
38
+
39
+ it "reflects a required property into a schema" do
40
+ data = {
41
+ "parameters" => [
42
+ {
43
+ "name" => "limit",
44
+ "required" => true,
45
+ }
46
+ ]
47
+ }
48
+ schema, schema_data = call(data)
49
+
50
+ assert_nil schema_data
51
+ assert_equal ["limit"], schema.required
52
+ end
53
+
54
+ it "reflects an array with an items schema into a schema" do
55
+ data = {
56
+ "parameters" => [
57
+ {
58
+ "name" => "tags",
59
+ "type" => "array",
60
+ "minItems" => 1,
61
+ "maxItems" => 10,
62
+ "uniqueItems" => true,
63
+ "items" => {
64
+ "type" => "string"
65
+ }
66
+ }
67
+ ]
68
+ }
69
+ schema, schema_data = call(data)
70
+
71
+ assert_nil schema_data
72
+ assert_equal ["array"], schema.properties["tags"].type
73
+ assert_equal 1, schema.properties["tags"].min_items
74
+ assert_equal 10, schema.properties["tags"].max_items
75
+ assert_equal true, schema.properties["tags"].unique_items
76
+ assert_equal({ "type" => "string" }, schema.properties["tags"].items)
77
+ end
78
+
79
+ it "reflects a enum property into a schema" do
80
+ data = {
81
+ "parameters" => [
82
+ {
83
+ "name" => "type",
84
+ "type" => "string",
85
+ "enum" => ["hoge", "fuga"]
86
+ }
87
+ ]
88
+ }
89
+ schema, schema_data = call(data)
90
+
91
+ assert_nil schema_data
92
+ assert_equal ["hoge", "fuga"], schema.properties["type"].enum
93
+ end
94
+
95
+ it "reflects string properties into a schema" do
96
+ data = {
97
+ "parameters" => [
98
+ {
99
+ "name" => "password",
100
+ "type" => "string",
101
+ "format" => "password",
102
+ "pattern" => "[a-zA-Z0-9]+",
103
+ "minLength" => 6,
104
+ "maxLength" => 30
105
+ }
106
+ ]
107
+ }
108
+ schema, schema_data = call(data)
109
+
110
+ assert_nil schema_data
111
+ assert_equal "password", schema.properties["password"].format
112
+ assert_equal Regexp.new("[a-zA-Z0-9]+"), schema.properties["password"].pattern
113
+ assert_equal 6, schema.properties["password"].min_length
114
+ assert_equal 30, schema.properties["password"].max_length
115
+ end
116
+
117
+ it "reflects number properties into a schema" do
118
+ data = {
119
+ "parameters" => [
120
+ {
121
+ "name" => "limit",
122
+ "type" => "integer",
123
+ "minimum" => 20,
124
+ "exclusiveMinimum" => true,
125
+ "maximum" => 100,
126
+ "exclusiveMaximum" => false,
127
+ "multipleOf" => 10
128
+ }
129
+ ]
130
+ }
131
+ schema, schema_data = call(data)
132
+
133
+ assert_nil schema_data
134
+ assert_equal 20, schema.properties["limit"].min
135
+ assert_equal true, schema.properties["limit"].min_exclusive
136
+ assert_equal 100, schema.properties["limit"].max
137
+ assert_equal false, schema.properties["limit"].max_exclusive
138
+ assert_equal 10, schema.properties["limit"].multiple_of
139
+ end
140
+
141
+ it "returns schema data for a body parameter" do
142
+ data = {
143
+ "parameters" => [
144
+ {
145
+ "name" => "payload",
146
+ "in" => "body",
147
+ "schema" => {
148
+ "$ref" => "#/definitions/foo",
149
+ }
150
+ }
151
+ ]
152
+ }
153
+ schema, schema_data = call(data)
154
+
155
+ assert_nil schema
156
+ assert_equal({ "$ref" => "#/definitions/foo" }, schema_data)
157
+ end
158
+
159
+ it "requires that certain fields are present" do
160
+ data = {
161
+ "parameters" => [
162
+ {
163
+ }
164
+ ]
165
+ }
166
+ e = assert_raises ArgumentError do
167
+ call(data)
168
+ end
169
+ assert_equal "Committee: no name section in link data.", e.message
170
+ end
171
+
172
+ it "requires that body parameters not be mixed with form parameters" do
173
+ data = {
174
+ "parameters" => [
175
+ {
176
+ "name" => "payload",
177
+ "in" => "body",
178
+ },
179
+ {
180
+ "name" => "limit",
181
+ "in" => "form",
182
+ },
183
+ ]
184
+ }
185
+ e = assert_raises ArgumentError do
186
+ call(data)
187
+ end
188
+ assert_equal "Committee: can't mix body parameter with form parameters.",
189
+ e.message
190
+ end
191
+
192
+ def call(data)
193
+ Committee::Drivers::OpenAPI2::ParameterSchemaBuilder.new(data).call
194
+ end
195
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ describe Committee::Drivers::OpenAPI3::Driver do
6
+ before do
7
+ @driver = Committee::Drivers::OpenAPI3::Driver.new
8
+ end
9
+
10
+ it "has a name" do
11
+ assert_equal :open_api_3, @driver.name
12
+ end
13
+
14
+ it "has a schema class" do
15
+ assert_equal Committee::Drivers::OpenAPI3::Schema, @driver.schema_class
16
+ end
17
+
18
+ it "override methods" do
19
+ parser = OpenAPIParser.parse(open_api_3_data, strict_reference_validation: false)
20
+ schema = @driver.parse(parser)
21
+
22
+ assert_kind_of Committee::Drivers::OpenAPI3::Schema, schema
23
+ assert_kind_of OpenAPIParser::Schemas::OpenAPI, schema.open_api
24
+ assert_equal @driver, schema.driver
25
+ end
26
+
27
+ it "defaults to coercing form parameters" do
28
+ assert_equal true, @driver.default_coerce_form_params
29
+ end
30
+
31
+ it "defaults to path parameters" do
32
+ assert_equal true, @driver.default_path_params
33
+ end
34
+
35
+ it "defaults to query parameters" do
36
+ assert_equal true, @driver.default_query_params
37
+ end
38
+
39
+ describe "Schema" do
40
+ describe "#operation_object" do
41
+ describe "path template" do
42
+ it "gets a normal path" do
43
+ obj = open_api_3_schema.operation_object("/path_template_test/no_template", "get")
44
+ assert_equal "/path_template_test/no_template", obj.original_path
45
+ end
46
+
47
+ it "gets a template path" do
48
+ obj = open_api_3_schema.operation_object("/path_template_test/test", "get")
49
+ assert_equal "/path_template_test/{template_name}", obj.original_path
50
+ end
51
+
52
+ it "gets a nested template path" do
53
+ obj = open_api_3_schema.operation_object("/path_template_test/abc/nested", "get")
54
+ assert_equal "/path_template_test/{template_name}/nested", obj.original_path
55
+ assert_equal({"template_name"=>"abc"}, obj.path_params)
56
+ end
57
+
58
+ it "gets a double nested template path" do
59
+ obj = open_api_3_schema.operation_object("/path_template_test/test/nested/abc", "get")
60
+ assert_equal "/path_template_test/{template_name}/nested/{nested_parameter}", obj.original_path
61
+ assert_equal({"template_name"=>"test", "nested_parameter" => "abc"}, obj.path_params)
62
+ end
63
+
64
+ it "gets a twice nested template path" do
65
+ obj = open_api_3_schema.operation_object("/path_template_test/test/abc", "get")
66
+ assert_equal "/path_template_test/{template_name}/{nested_parameter}", obj.original_path
67
+ assert_equal({"template_name"=>"test", "nested_parameter" => "abc"}, obj.path_params)
68
+ end
69
+
70
+ it "gets a twice nested concrete path" do
71
+ obj = open_api_3_schema.operation_object("/path_template_test/test/abc/finish", "get")
72
+ assert_equal "/path_template_test/{template_name}/{nested_parameter}/finish", obj.original_path
73
+ assert_equal({"template_name"=>"test", "nested_parameter" => "abc"}, obj.path_params)
74
+ end
75
+
76
+ it "gets an ambiguous path" do
77
+ obj = open_api_3_schema.operation_object("/ambiguous/no_template", "get")
78
+ assert_equal "/{ambiguous}/no_template", obj.original_path
79
+ assert_equal({"ambiguous"=>"ambiguous"}, obj.path_params)
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end