nicolas-cajelli/api-documenter

0.1.0 2017-08-14 19:44 UTC

This package is not auto-updated.

Last update: 2024-09-29 04:20:14 UTC


README

此库旨在在定义的范围内以尽可能小的摩擦自动构建文档(见 范围)。如果您的用例与当前范围不符,请创建问题/PR

范围

正在运行的API

  • PHP 7.1 或更高版本(由gson要求)
  • 具有类似 Slim 框架 结构的隔离路由文件

安装

composer require nicolas-cajelli/api-documenter

运行(默认)

./vendor/bin/build-documentation src/routes.php "My api name" "/my/api/basepath"

运行(自定义)

在您的项目中创建一个 .php 文件

<?php
$loader = require 'vendor/autoload.php';

# Required by gson library
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader([$loader, 'loadClass']);

$app = new \Documenter\FakeApp('My api name');
$app->setBasePath('/my/api/basepath');
$app->setDescription('My api description');
$app->setVersion('1.0.0');

require 'src/routes.php';

$formatter = new \Documenter\Formatter\SwaggerFormatter();

echo $formatter->getDocumentation($app);