@@ -193,7 +193,10 @@ public function appendRequestRules(array $controllersInfo): array
193193 continue ;
194194 }
195195 $ params = $ reflectionMethod ->getParameters ();
196- $ customRules = $ this ->customParamsDocComment ($ reflectionMethod ->getDocComment ());
196+ $ docComment = $ reflectionMethod ->getDocComment ();
197+ $ customRules = $ this ->customParamsDocComment ($ docComment );
198+ $ customResponses = $ this ->customResponsesDocComment ($ docComment );
199+ $ controllersInfo [$ index ]['responses ' ] = $ customResponses ;
197200 $ controllersInfo [$ index ]['rules ' ] = [];
198201
199202 foreach ($ params as $ param ) {
@@ -214,7 +217,7 @@ public function appendRequestRules(array $controllersInfo): array
214217 //throw $th;
215218 }
216219
217- foreach (config ('request-docs.request_methods ' ) as $ requestMethod ) {
220+ foreach (config ('request-docs.rules_methods ' ) as $ requestMethod ) {
218221 if ($ requestClass && method_exists ($ requestClass , $ requestMethod )) {
219222 try {
220223 $ controllersInfo [$ index ]['rules ' ] = array_merge ($ controllersInfo [$ index ]['rules ' ], $ this ->flattenRules ($ requestClass ->$ requestMethod ()));
@@ -326,14 +329,38 @@ private function customParamsDocComment($docComment): array
326329 if (Str::contains ($ comment , '@LRDparam ' )) {
327330 $ comment = trim (Str::replace (['@LRDparam ' , '* ' ], '' , $ comment ));
328331
329- $ comment = explode ( ' ' , $ comment );
332+ $ comment = $ this -> multiexplode ([ ' ' , ' | ' ] , $ comment );
330333
331334 if (count ($ comment ) > 0 ) {
332335 $ params [$ comment [0 ]] = array_values (array_filter ($ comment , fn ($ item ) => $ item != $ comment [0 ]));
333336 }
334337 }
335338 }
339+ return $ params ;
340+ }
341+ private function customResponsesDocComment ($ docComment ): array
342+ {
343+ $ params = [];
344+
345+ foreach (explode ("\n" , $ docComment ) as $ comment ) {
346+ if (Str::contains ($ comment , '@LRDresponses ' )) {
347+ $ comment = trim (Str::replace (['@LRDresponses ' , '* ' ], '' , $ comment ));
348+
349+ $ comment = $ this ->multiexplode ([' ' , '| ' ], $ comment );
336350
351+ $ params = $ comment ;
352+ }
353+ }
354+ if (count ($ params ) == 0 ) {
355+ $ params = config ('request-docs.default_responses ' ) ?? [];
356+ }
337357 return $ params ;
338358 }
359+
360+ private function multiexplode ($ delimiters , $ string )
361+ {
362+ $ ready = str_replace ($ delimiters , $ delimiters [0 ], $ string );
363+ $ launch = explode ($ delimiters [0 ], $ ready );
364+ return $ launch ;
365+ }
339366}
0 commit comments