Docs Generator

Usage

Documentation creation based on php attribute Sajya\Server\Attributes\RpcMethod:

declare(strict_types=1);

namespace App\Http\Procedures;

use Illuminate\Http\Request;
use Sajya\Server\Attributes\Procedure;
use Sajya\Server\Attributes\RpcMethod;

#[Procedure('math')]
class MathProcedure
{
    #[RpcMethod(
        description: "Performs a subtraction operation",
        params: [
            "minuend" => "int",
            "subtrahend" => "int",
        ],
        result: [
            "outcome" => "int",
        ]
    )]
    public function subtract(Request $request): array
    {
        return [
            'outcome' => $request->get('minuend') - $request->get('subtrahend'),
        ];
    }
}

Generating HTML

Run the documentations generator command from the root directory:

php artisan sajya:docs 'Route name'

By default, the file will be saved storage/app/api/docs.html, but you can change both path and filename with options:

php artisan sajya:docs rpc.endpoint --path='/api/v1/' --name="index.html"