File tree Expand file tree Collapse file tree 3 files changed +38
-13
lines changed Expand file tree Collapse file tree 3 files changed +38
-13
lines changed Original file line number Diff line number Diff line change 1717 */
1818class SecurityRequirements extends SpecBaseObject
1919{
20+ private $ _securityRequirements ;
21+
22+ public function __construct (array $ data )
23+ {
24+ parent ::__construct ($ data );
25+ $ this ->_securityRequirements = $ data ;
26+ }
27+
2028 /**
2129 * @return array array of attributes available in this object.
2230 */
@@ -37,4 +45,19 @@ protected function attributes(): array
3745 protected function performValidation ()
3846 {
3947 }
48+
49+ /**
50+ * @return mixed returns the serializable data of this object for converting it
51+ * to JSON or YAML.
52+ * TODO
53+ */
54+ public function getSerializableData ()
55+ {
56+ $ data = [];
57+ foreach ($ this ->_securityRequirements as $ name => $ securityRequirement ) {
58+ /** @var SecurityRequirement $securityRequirement */
59+ $ data [] = [$ name => json_decode (json_encode ($ securityRequirement ->getSerializableData ()), true )];
60+ }
61+ return $ data ;
62+ }
4063}
Original file line number Diff line number Diff line change 1111
1212class SecuritySchemes extends SpecBaseObject
1313{
14- private $ _securitySchemes = [] ;
14+ private $ _securitySchemes ;
1515
1616 public function __construct (array $ data )
1717 {
@@ -31,14 +31,15 @@ public function performValidation()
3131 /**
3232 * @return mixed returns the serializable data of this object for converting it
3333 * to JSON or YAML.
34+ * TODO
3435 */
3536 public function getSerializableData ()
3637 {
3738 $ data = [];
38- foreach ($ this ->_securitySchemes as $ securityScheme ) {
39- /** @var $securityScheme SecurityScheme */
40- $ data [$ securityScheme -> name ] = $ securityScheme ->scheme ;
39+ foreach ($ this ->_securitySchemes as $ name => $ securityScheme ) {
40+ /** @var SecurityScheme $securityScheme */
41+ $ data [$ name ] = $ securityScheme ->getSerializableData () ;
4142 }
4243 return (object ) $ data ;
4344 }
44- }
45+ }
Original file line number Diff line number Diff line change 66use cebe \openapi \spec \Response ;
77use cebe \openapi \spec \Responses ;
88use cebe \openapi \spec \SecurityRequirement ;
9+ use cebe \openapi \spec \SecurityRequirements ;
910use cebe \openapi \spec \SecurityScheme ;
1011use cebe \openapi \spec \SecuritySchemes ;
1112
@@ -200,19 +201,19 @@ public function testSecurityAtPathOperationLevel()
200201 $ openapi = $ this ->createOpenAPI ([
201202 'components ' => new Components ([
202203 'securitySchemes ' => new SecuritySchemes ([
203- new SecurityScheme ([
204- 'BearerAuth ' => [
205- 'type ' => 'http ' ,
206- 'scheme ' => 'bearer ' ,
207- 'bearerFormat ' => 'AuthToken and JWT Format ' # optional, arbitrary value for documentation purposes
208- ]
209- ])
204+ 'BearerAuth ' => new SecurityScheme ([
205+ 'type ' => 'http ' ,
206+ 'scheme ' => 'bearer ' ,
207+ 'bearerFormat ' => 'AuthToken and JWT Format ' # optional, arbitrary value for documentation purposes
208+ ]),
210209 ]),
211210 ]),
212211 'paths ' => [
213212 '/test ' => new PathItem ([
214213 'get ' => new Operation ([
215- 'security ' => [new SecurityRequirement (['BearerAuth ' => []])],
214+ 'security ' => new SecurityRequirements ([
215+ 'BearerAuth ' => new SecurityRequirement ([]),
216+ ]),
216217 'responses ' => new Responses ([
217218 200 => new Response (['description ' => 'OK ' ]),
218219 ])
You can’t perform that action at this time.
0 commit comments