waxwink/docgen

A laravel package for dynamic API documentation generating

Installs: 46

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Language:JavaScript

dev-master 2020-01-02 05:57 UTC

This package is auto-updated.

Last update: 2024-10-29 05:59:24 UTC


README

If you need a minimal API documentation quickly for your front end team, this package might help you.

Instruction

For installing just use the following command:

composer require waxwink/docgen

After that publish the necessary js ans css files to public folder for the documentation view:

php artisan vendor:publish --tag=public

This package can now work by going to /routes url but for more complete api documentation you need to follow some rules in your laravel app:

Request Body

For including the request body of each route to the documentation you must use a FormRequest object as a input parameter in the related controller. DocGen will use that request object to resolve the request body and the rules will be shown exactly like what is written in the rules method of the request object.

Output Keys

For including the output keys of a route every route should use a JsonResource to show the output. DocGen must be aware of this resource by put it as doc block (with @DG-Resource) in the controller method as follows:

    /**
     * @DG-Resource App\Http\Resources\OrderResource
     *
     * @param OrderRequest $request
     * @return AnonymousResourceCollection
     */
    public function index(OrderRequest $request)
    {
        //....
    }