@@ -77,39 +77,47 @@ protected function prepareOperation(Operation $operation)
77
77
$ operation = clone $ operation ;
78
78
$ operation ->path = $ this ->swagger ->basePath . $ operation ->path ;
79
79
80
- /**
81
- * I don't known How will be better
82
- * But I am going to add a new required Parameter to check this in Request Scheme
83
- */
84
80
if ($ operation ->security ) {
85
- foreach ($ operation ->security as $ security ) {
86
- parent ::assertInternalType (
87
- 'array ' ,
88
- $ security ,
89
- 'Operation->security must be array of objects '
90
- );
81
+ $ this ->addParametersFromSecurity ($ operation );
82
+ }
91
83
92
- $ name = key ($ security );
84
+ return $ operation ;
85
+ }
93
86
94
- $ securityDefinition = $ this ->getSecurityByName ($ name );
95
- parent ::assertInternalType (
96
- 'object ' ,
97
- $ securityDefinition ,
98
- "Unknown security definition {$ name }"
99
- );
100
87
101
- $ operation ->parameters [] = new Parameter (
102
- [
103
- 'name ' => $ securityDefinition ->name ,
104
- 'in ' => $ securityDefinition ->in ,
105
- 'description ' => $ securityDefinition ->description ,
106
- 'required ' => true
107
- ]
108
- );
109
- }
110
- }
88
+ /**
89
+ * I don't known How will be better
90
+ * But I am going to add a new required Parameter to check this in Request Scheme
91
+ *
92
+ * @param Operation $operation
93
+ */
94
+ protected function addParametersFromSecurity (Operation $ operation )
95
+ {
96
+ foreach ($ operation ->security as $ security ) {
97
+ parent ::assertInternalType (
98
+ 'array ' ,
99
+ $ security ,
100
+ 'Operation->security must be array of objects '
101
+ );
111
102
112
- return $ operation ;
103
+ $ name = key ($ security );
104
+
105
+ $ securityDefinition = $ this ->getSecurityByName ($ name );
106
+ parent ::assertInternalType (
107
+ 'object ' ,
108
+ $ securityDefinition ,
109
+ "Unknown security definition {$ name }"
110
+ );
111
+
112
+ $ operation ->parameters [] = new Parameter (
113
+ [
114
+ 'name ' => $ securityDefinition ->name ,
115
+ 'in ' => $ securityDefinition ->in ,
116
+ 'description ' => $ securityDefinition ->description ,
117
+ 'required ' => true
118
+ ]
119
+ );
120
+ }
113
121
}
114
122
115
123
/**
@@ -208,6 +216,11 @@ public function findResponseByStatusCode(Operation $path, $statusCode = 200)
208
216
*/
209
217
public function assertHttpResponseForOperation (Response $ httpResponse , Operation $ path , $ statusCode = 200 )
210
218
{
219
+ // User can mutate Operation->security, and we should re-enable it
220
+ if ($ path ->security ) {
221
+ $ this ->addParametersFromSecurity ($ path );
222
+ }
223
+
211
224
$ response = $ this ->findResponseByStatusCode ($ path , $ statusCode );
212
225
if ($ response ) {
213
226
return $ this ->assertHttpResponseForOperationResponse (
0 commit comments