Skip to content

Commit 1ada9e1

Browse files
committed
added description parsing library, more useful summary message
1 parent 6cb7a6a commit 1ada9e1

File tree

7 files changed

+286
-290
lines changed

7 files changed

+286
-290
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Laravel Swagger
22

3-
This package scans your laravel project's routes and auto generates a Swagger 2.0 documentation for you. If you inject Form Request classes in your controller's actions as request validation, it will also generate the parameters for each request that has them. It will take into account wether the request is a GET/HEAD/DELETE or a POST/PUT/PATCH request and make its best guess as to the type of parameter object it should generate. It will also generate the path parameters if you route contains them. Finally, this package will also scan any documentation you have in your action methods and add it as description to that path, along with any appropriate annotations such as @deprecated.
3+
This package scans your laravel project's routes and auto generates a Swagger 2.0 documentation for you. If you inject Form Request classes in your controller's actions as request validation, it will also generate the parameters for each request that has them. It will take into account wether the request is a GET/HEAD/DELETE or a POST/PUT/PATCH request and make its best guess as to the type of parameter object it should generate. It will also generate the path parameters if your route contains them. Finally, this package will also scan any documentation you have in your action methods and add it as summary and description to that path, along with any appropriate annotations such as @deprecated.
4+
5+
One thing to note is this library leans on being explicit. It will choose to include keys even if they have a default. For example it chooses to say a route has a deprecated value of false rather than leaving it out. I believe this makes reading the documentation easier by not leaving important information out. The file can be easily cleaned up afterwards if the user chooses to leave out the defaults.
46

57
## Installation
68

@@ -33,6 +35,9 @@ Your sample controller might look like this:
3335
/**
3436
* Return all the details of a user
3537
*
38+
* Returns the user's first name, last name and address
39+
* Please see the documentation [here](https://example.com/users) for more information
40+
*
3641
* @deprecated
3742
*/
3843
class UserController extends Controller
@@ -73,8 +78,9 @@ Running `php artisan laravel-swagger:generate > swagger.json` will generate the
7378
"paths": {
7479
"\/api\/user\/{id}": {
7580
"get": {
76-
"summary": "GET \/api\/user\/{id}",
77-
"description": "Return all the details of a user",
81+
"summary": "Return all the details of a user",
82+
"description": "Returns the user's first name, last name and address
83+
Please see the documentation [here](https://example.com/users) for more information",
7884
"deprecated": true
7985
"responses": {
8086
"200": {

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@
3434
"Mtrajano\\LaravelSwagger\\SwaggerServiceProvider"
3535
]
3636
}
37+
},
38+
"require": {
39+
"phpdocumentor/reflection-docblock": "^4.3"
3740
}
3841
}

0 commit comments

Comments
 (0)