80
80
parameters: new Parameters ([new QueryParameter (key: 'q ' ), new HeaderParameter (key: 'q ' )]),
81
81
provider: [self ::class, 'headerAndQueryProvider ' ]
82
82
)]
83
+ #[GetCollection(
84
+ uriTemplate: 'header_required ' ,
85
+ parameters: [
86
+ 'Req ' => new HeaderParameter (required: true , schema: ['type ' => 'string ' ]),
87
+ ],
88
+ provider: [self ::class, 'headerProvider ' ]
89
+ )]
83
90
#[QueryParameter(key: 'everywhere ' )]
84
91
class WithParameter
85
92
{
@@ -128,7 +135,7 @@ public static function restrictAccess(): void
128
135
throw new AccessDeniedHttpException ();
129
136
}
130
137
131
- public static function headerAndQueryProvider (Operation $ operation , array $ uriVariables = [], array $ context = [])
138
+ public static function headerAndQueryProvider (Operation $ operation , array $ uriVariables = [], array $ context = []): JsonResponse
132
139
{
133
140
$ parameters = $ operation ->getParameters ();
134
141
$ values = [$ parameters ->get ('q ' , HeaderParameter::class)->getValue (), $ parameters ->get ('q ' , QueryParameter::class)->getValue ()];
@@ -155,4 +162,12 @@ public static function toInt(Parameter $parameter, array $parameters = [], array
155
162
156
163
return $ operation ->withParameters ($ parameters );
157
164
}
165
+
166
+ public static function headerProvider (Operation $ operation , array $ uriVariables = [], array $ context = []): JsonResponse
167
+ {
168
+ $ parameters = $ operation ->getParameters ();
169
+ $ values = [$ parameters ->get ('Req ' , HeaderParameter::class)->getValue ()];
170
+
171
+ return new JsonResponse ($ values );
172
+ }
158
173
}
0 commit comments