thunken / doc-doc-goose
A laravel REST API doc generator
Requires
- illuminate/support: ~5.5.0|~5.6.0|~5.7.0|~5.8.0||~5.9.0|^6.0
- mpociot/laravel-apidoc-generator: ^4.2
Requires (Dev)
- laravel/framework: ~5.5.0|~5.6.0|~5.7.0|~5.8.0||~5.9.0|^6.0
- phpunit/phpcov: ~3.0|~4.0
- phpunit/phpunit: ~5.7.14|~6.1|~7.0
README
Generates a clean HTML'd API documentation. Based on your routes declarations and filtered patterns.
Install
composer require thunken/doc-doc-goose
Add
Thunken\DocDocGoose\DocDocGooseProvider::class,
in config/app.php providers array
Publish files (if you need some tweaks on config and views)
php artisan vendor:publish --provider="Thunken\DocDocGoose\DocDocGooseProvider"
Config changes
return [ 'routes' => [ 'v1' => [ 'patterns' => [ 'api.v1.*' ], 'rules' => [ 'headers' => [ 'Authorization' => '<Your API Key>' ] ] ] ], 'cache' => [ 'enabled' => true, 'store' => 'file' ] ];
Here you can manage versions, headers by version and caching feature.
Cache
Cache is enable by default and using the file store, you can disable it by putting 'enable' to false.
File cache is the best cache method if your cache files are not persisted across deployment. It's a good way to ensure your documentation is up to date with the current version of your API code at each deployment. You can reproduce this behavior by resetting the Extractor::cacheName key in your choosen cache store.
Facade
Already declared in provider so this should be useless. Still, to do so, add
'Extractor' => Thunken\DocDocGoose\Facades\Extractor::class,
in config/app.php facades array
Usage
In views
As simple as injecting
{!! \Extractor::renderMenu() !!}
and / or
{!! \Extractor::renderContent() !!}
in your templates.
Use the raw extractor output
$extractor = app(Extractor::class); $extractor->extract(); /** @var array $docsAsArray */ $docAsArray = $extractor->toArray(); // returns an array /** @var Collection $docsAsGroups */ $docsAsGroups = $extractor->toRaw(); // returns a Group Collection
@TODOs
- Goals description
- Tests
- Tests
- And Tests
References and thanks
- Widely and wisely using https://github.com/mpociot/laravel-apidoc-generator library (Thanks)