thunken/doc-doc-goose

This package is abandoned and no longer maintained. No replacement package was suggested.

A laravel REST API doc generator

1.6.8 2020-07-29 16:04 UTC

This package is auto-updated.

Last update: 2022-03-13 16:31:33 UTC


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