File tree Expand file tree Collapse file tree 5 files changed +15
-62
lines changed Expand file tree Collapse file tree 5 files changed +15
-62
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public function __construct(array $data)
2424 parent ::__construct ($ data );
2525
2626 $ read = true ;
27- foreach ($ data as $ index => $ value ) {
27+ foreach ($ data as $ index => $ value ) {
2828 if (is_numeric ($ index )) { // read
2929 $ requirements = $ value ;
3030 $ this ->_securityRequirements [array_keys ($ value )[0 ]] = new SecurityRequirement (array_values ($ value )[0 ]);
@@ -34,6 +34,9 @@ public function __construct(array $data)
3434 $ this ->_securityRequirements [$ index ] = $ value ;
3535 }
3636 }
37+ if ($ data === []) {
38+ $ this ->_securityRequirements = [];
39+ }
3740 }
3841
3942 /**
@@ -71,6 +74,11 @@ public function getSerializableData()
7174
7275 public function getRequirement (string $ name )
7376 {
74- return $ this ->_securityRequirements [$ name ] ?? 'nul5l ' ;
77+ return $ this ->_securityRequirements [$ name ] ?? null ;
78+ }
79+
80+ public function getRequirements ()
81+ {
82+ return $ this ->_securityRequirements ;
7583 }
7684}
Original file line number Diff line number Diff line change 2525 */
2626class SecurityScheme extends SpecBaseObject
2727{
28- public $ name ;
29- public $ scheme ;
3028 private $ knownTypes = [
3129 "apiKey " ,
3230 "http " ,
3331 "oauth2 " ,
3432 "openIdConnect "
3533 ];
3634
37- public function __construct (array $ data )
38- {
39- parent ::__construct ($ data );
40- $ this ->name = array_keys ($ data )[0 ];
41- $ this ->scheme = array_values ($ data )[0 ];
42- }
43-
4435 /**
4536 * @return array array of attributes available in this object.
4637 */
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 88use cebe \openapi \spec \SecurityRequirement ;
99use cebe \openapi \spec \SecurityRequirements ;
1010use cebe \openapi \spec \SecurityScheme ;
11- use cebe \openapi \spec \SecuritySchemes ;
1211
1312class WriterTest extends \PHPUnit \Framework \TestCase
1413{
@@ -204,13 +203,13 @@ public function testSecurityAtPathOperationLevel()
204203 {
205204 $ openapi = $ this ->createOpenAPI ([
206205 'components ' => new Components ([
207- 'securitySchemes ' => new SecuritySchemes ( [
206+ 'securitySchemes ' => [
208207 'BearerAuth ' => new SecurityScheme ([
209208 'type ' => 'http ' ,
210209 'scheme ' => 'bearer ' ,
211210 'bearerFormat ' => 'AuthToken and JWT Format ' # optional, arbitrary value for documentation purposes
212211 ]),
213- ]) ,
212+ ],
214213 ]),
215214 'paths ' => [
216215 '/test ' => new PathItem ([
Original file line number Diff line number Diff line change @@ -199,10 +199,10 @@ public function testDefaultSecurity()
199199YAML
200200 );
201201
202- $ this ->assertSame ([], $ openapi ->paths ->getPath ('/path/one ' )->post ->security );
202+ $ this ->assertSame ([], $ openapi ->paths ->getPath ('/path/one ' )->post ->security -> getRequirements () );
203203 $ this ->assertSame (null , $ openapi ->paths ->getPath ('/path/two ' )->post ->security );
204204
205- $ this ->assertCount (1 , $ openapi ->security );
206- $ this ->assertSame ([], $ openapi ->security [ 0 ]-> Bearer );
205+ $ this ->assertCount (1 , $ openapi ->security -> getRequirements () );
206+ $ this ->assertSame ([], $ openapi ->security -> getRequirement ( ' Bearer ' )-> getSerializableData () );
207207 }
208208}
You can’t perform that action at this time.
0 commit comments