@@ -141,6 +141,7 @@ protected function generatePath()
141
141
142
142
$ this ->docs ['paths ' ][$ this ->uri ][$ this ->method ] = [
143
143
'description ' => "$ methodDescription {$ this ->uri }" ,
144
+ 'summary ' => '' ,
144
145
'tags ' => [],
145
146
'responses ' => [
146
147
'200 ' => [
@@ -175,7 +176,11 @@ protected function getFormRules()
175
176
176
177
$ parsedAction = Str::parseCallback ($ this ->action );
177
178
178
- $ parameters = (new ReflectionMethod ($ parsedAction [0 ], $ parsedAction [1 ]))->getParameters ();
179
+ $ reflector = (new ReflectionMethod ($ parsedAction [0 ], $ parsedAction [1 ]));
180
+ $ parameters = $ reflector ->getParameters ();
181
+ $ docComment = $ reflector ->getDocComment ();
182
+
183
+ $ this ->addDescription ($ docComment );
179
184
180
185
foreach ($ parameters as $ parameter ) {
181
186
$ class = (string ) $ parameter ->getType ();
@@ -186,6 +191,35 @@ protected function getFormRules()
186
191
}
187
192
}
188
193
194
+ protected function addDescription ($ docComment )
195
+ {
196
+ $ docDomment = $ this ->getDescription ($ docComment );
197
+ $ this ->docs ['paths ' ][$ this ->uri ][$ this ->method ]['description ' ] = $ docDomment ;
198
+ }
199
+
200
+ protected function getDescription ($ docComment )
201
+ {
202
+ $ docCommentParsed = trim (str_replace (array ('/ ' , '* ' ), '' , substr ($ docComment , 0 , strpos ($ docComment , '@ ' ))));
203
+ $ docComment = trim (preg_replace ('/\s+/ ' , ' ' , $ docCommentParsed ));
204
+
205
+ return $ docComment ;
206
+ }
207
+
208
+ protected function addSummary ($ actionName )
209
+ {
210
+ $ actionName = $ this ->getActionName ($ actionName );
211
+ $ this ->docs ['paths ' ][$ this ->uri ][$ this ->method ]['summary ' ] = $ actionName ;
212
+ }
213
+
214
+ protected function getActionName ($ actionName )
215
+ {
216
+ $ actionNameSubString = substr ($ actionName , strpos ($ actionName , '@ ' )+1 );
217
+ $ actionNameArray = preg_split ('/(?=[A-Z])/ ' , ucfirst ($ actionNameSubString ));
218
+ $ actionName = trim (implode (' ' , $ actionNameArray ));
219
+
220
+ return $ actionName ;
221
+ }
222
+
189
223
protected function addTags ($ controllerArray )
190
224
{
191
225
$ tagName = $ this ->getControllerName ($ controllerArray );
0 commit comments