File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ private function docsToOpenApi(array $docs): void
5757 $ this ->openApi ['paths ' ][$ uriLeadingSlash ][$ httpMethod ]['parameters ' ][] = $ this ->makePathParameterItem ($ parameter , $ rule );
5858 }
5959
60- $ this ->openApi ['paths ' ][$ uriLeadingSlash ][$ httpMethod ]['responses ' ] = config ( ' request-docs.open_api.responses ' , [] );
60+ $ this ->openApi ['paths ' ][$ uriLeadingSlash ][$ httpMethod ]['responses ' ] = $ this -> setAndFilterResponses ( $ doc );
6161
6262 foreach ($ doc ->getRules () as $ attribute => $ rules ) {
6363 foreach ($ rules as $ rule ) {
@@ -90,6 +90,19 @@ private function docsToOpenApi(array $docs): void
9090 }
9191 }
9292 }
93+ protected function setAndFilterResponses (Doc $ doc ): array
94+ {
95+ $ docResponses = $ doc ->getResponses ();
96+ $ configResponses = config ('request-docs.open_api.responses ' , []);
97+ if (empty ($ docResponses ) || empty ($ configResponses )) {
98+ return $ configResponses ;
99+ }
100+ $ rtn = [];
101+ foreach ($ docResponses as $ responseCode ) {
102+ $ rtn [$ responseCode ] = $ configResponses [$ responseCode ] ?? $ configResponses ['default ' ] ?? [];
103+ }
104+ return $ rtn ;
105+ }
93106
94107 protected function attributeIsFile (string $ rule ): bool
95108 {
You can’t perform that action at this time.
0 commit comments