File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ protected function attributes(): array
51
51
];
52
52
}
53
53
54
+ protected function attributeDefaults (): array
55
+ {
56
+ return [
57
+ 'security ' => null ,
58
+ ];
59
+ }
60
+
54
61
/**
55
62
* Perform validation on this object, check data against OpenAPI Specification rules.
56
63
*
Original file line number Diff line number Diff line change @@ -170,4 +170,39 @@ public function testSecurityRequirement()
170
170
171
171
$ this ->assertSame (['write:pets ' , 'read:pets ' ], $ securityRequirement ->petstore_auth );
172
172
}
173
+
174
+ public function testDefaultSecurity ()
175
+ {
176
+ $ openapi = Reader::readFromYaml (<<<YAML
177
+ paths:
178
+ /path/one:
179
+ post:
180
+ description: path one
181
+ # [...]
182
+ security: [] # default security
183
+
184
+ /path/two:
185
+ post:
186
+ description: path two
187
+ # [...]
188
+ # No security entry defined there
189
+
190
+ components:
191
+ securitySchemes:
192
+ Bearer:
193
+ type: http
194
+ scheme: bearer
195
+ bearerFormat: JWT
196
+
197
+ security:
198
+ - Bearer: []
199
+ YAML
200
+ );
201
+
202
+ $ this ->assertSame ([], $ openapi ->paths ->getPath ('/path/one ' )->post ->security );
203
+ $ this ->assertSame (null , $ openapi ->paths ->getPath ('/path/two ' )->post ->security );
204
+
205
+ $ this ->assertCount (1 , $ openapi ->security );
206
+ $ this ->assertSame ([], $ openapi ->security [0 ]->Bearer );
207
+ }
173
208
}
You can’t perform that action at this time.
0 commit comments