Package Data | |
---|---|
Maintainer Username: | TadasPaplauskas |
Maintainer Contact: | tadaspaplauskas@gmail.com (Tadas Paplauskas) |
Package Create Date: | 2016-01-21 |
Package Last Update: | 2016-09-27 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-10-27 15:24:09 |
Package Statistics | |
---|---|
Total Downloads: | 998 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 1 |
Total Forks: | 2 |
Total Open Issues: | 0 |
A simple plug-and-play Laravel 5 package that will generate a nice API documentation page based on your documented routes.
Do NOT install this package on your production environment unless you intend to make your API documentation public. In most cases it's best to keep it in the development environment.
Run this in your project folder:
composer require paplauskas/apidocs --dev
Add this to the config/app.php providers:
Paplauskas\ApiDocs\ApiDocsServiceProvider::class,
That's it!
If setting up ApiDocs went well, you should be able to access it through /apidocs route (for example http://website.dev/apidocs).
Please note that you still have to document your endpoints by hand - ain't no magic here.
Just write comments right next to your routes. Api endpoint description format is pretty similar to the usual DocBlocks format. Write comments right before the route you wish to document. Example:
/**
* @title Upload an image
* @description Uploads the original image to the server, resizes it.
* @group Images
* @param image
* @param scale
* @return stored image url
*/
Route::post('images/upload', 'ImageController@upload');
/**
* Get image
* Returns image info
* @group Images
* @param imageID
* @return path
* @return alt
* @return width
* @return height
*/
Route::get('images/{imageID}', 'ImageController@show');
As you probably noticed, @ title and @ description are optional tags - the first line is always treated as a title. @param, @return can be declared in several lines if you want to. Description line is optional and doesn't have to be specified at all. Use whatever format is more readable to you.
Package is smart enough to recognise group prefixes, so don't worry about them.
Undocumented routes are ignored.
ApiDocs checks for routes in the usual locations:
File an issue in issue tracker.