@@ -57,14 +57,24 @@ protected function attributes(): array
5757 ];
5858 }
5959
60+ private $ _attributeDefaults = [];
61+
62+ /**
63+ * @return array array of attributes default values.
64+ */
65+ protected function attributeDefaults (): array
66+ {
67+ return $ this ->_attributeDefaults ;
68+ }
69+
6070 /**
6171 * Create an object from spec data.
6272 * @param array $data spec data read from YAML or JSON
6373 * @throws TypeErrorException in case invalid data is supplied.
6474 */
6575 public function __construct (array $ data )
6676 {
67- if (! isset ( $ data [ ' style ' ]) && isset ($ data ['in ' ])) {
77+ if (isset ($ data ['in ' ])) {
6878 // Spec: Default values (based on value of in):
6979 // for query - form;
7080 // for path - simple;
@@ -73,17 +83,19 @@ public function __construct(array $data)
7383 switch ($ data ['in ' ]) {
7484 case 'query ' :
7585 case 'cookie ' :
76- $ data ['style ' ] = 'form ' ;
86+ $ this ->_attributeDefaults ['style ' ] = 'form ' ;
87+ $ this ->_attributeDefaults ['explode ' ] = true ;
7788 break ;
7889 case 'path ' :
7990 case 'header ' :
80- $ data ['style ' ] = 'simple ' ;
91+ $ this ->_attributeDefaults ['style ' ] = 'simple ' ;
92+ $ this ->_attributeDefaults ['explode ' ] = false ;
8193 break ;
8294 }
8395 }
84- if (! isset ( $ data [ ' explode ' ]) && isset ($ data ['style ' ])) {
96+ if (isset ($ data ['style ' ])) {
8597 // Spec: When style is form, the default value is true. For all other styles, the default value is false.
86- $ data ['explode ' ] = ($ data ['style ' ] === 'form ' );
98+ $ this -> _attributeDefaults ['explode ' ] = ($ data ['style ' ] === 'form ' );
8799 }
88100 parent ::__construct ($ data );
89101 }
0 commit comments