美味的/懒汉

用于生成Swagger json的轻量级中间件,可用于与Swagger UI一起使用

0.3.0 2014-09-26 04:41 UTC

This package is not auto-updated.

Last update: 2024-09-14 11:48:29 UTC


README

A Slim PHP 中间件,用于生成用于Swagger UI的swagger json。此中间件将自动为所有带有Swagger文档注释的类添加swagger json端点。使用 Zircote Swagger-php 来解析注释。

使用Composer安装

{
    "require": {
        "scrumptious\slagger": "0.3.0"
    }
}

用法

$app = new \Slim\Slim();

// Inject as Slim application middleware
$app->add(new \Slagger\Slagger('/api/v1/docs', __DIR__.'/../lib'));

\\ ... your app code

$app->run();

然后您需要在Swagger-UI界面中输入URL http://yourapidomain.com/api/v1/docs

Slagger(docsuri, scandir, options)

构造函数最多接受三个参数。

####docsuri 应用程序中返回swagger json的URI。

####scandir 扫描带有Swagger注释的文件的目录。

####options [可选] 传递给 Zircote swagger-php 库的 getResource 函数的选项。

注释

Zircote Swagger-php 库将解析您的文件中的Swagger注释。有关支持哪些注释的信息,请参阅 Swagger-php 文档

示例

/**
 * @SWG\Resource(
 *     apiVersion="0.1",
 *     swaggerVersion="1.2",
 *     resourcePath="/journey",
 *     basePath="http://myapi.com/api/v1"
 * )
 */
class Journey extends CRUD {
	// ...
}