avtehnik/service-doc

service-doc - Generate interactive documentation for your RESTful API using phpdoc annotations

Installs: 7 564

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Language:JavaScript

v0.1.3 2021-02-12 08:02 UTC

This package is auto-updated.

Last update: 2024-04-12 14:28:20 UTC


README

composer require avtehnik/service-doc

Usage

Add annotations to your php files.

/**
 * @ServiceDoc\Info(title="My First API", version="0.1")
 */

/**
 * @ServiceDoc\PathItem(
 *     microservice="payment",
 *     path="/wallet-prices",
 *     method="get",
 *     @ServiceDoc\Tag(
 *          name="user",
 *     )
 * )
 * @param $destination_code
 * @param $source_code
 *
 * @return
 */

Usage from Yii

Add servicedoc section to actions array

    class DocumentationController extends Controller
    {
        public function actions()
        {
            return [
                'servicedoc' => [
                    'class' => 'ServiceDoc\YiiServiceDocAction',
                    'scanDir' => [
                        Yii::getAlias('@common/components')
                    ],
                ],
            ];
        }
    }
    

and then you can access to docs with url /documentation/servicedoc

Usage from php

Generate always-up-to-date documentation.

<?php
require("vendor/autoload.php");
$swagger = \ServiceDoc\scan(__DIR__);
header('Content-type: application/json; charset=utf-8');
echo $swagger->toJson();