terwey / slim-swagger
Slim Middleware for generating Swagger documentation on the fly with Swagger-PHP
Requires
- zircote/swagger-php: ~0.9
This package is not auto-updated.
Last update: 2024-12-21 18:25:13 UTC
README
A Slim Middleware for generating Swagger documentation on the fly with Swagger-PHP.
Installation
Easiest is using Composer:
composer require terwey/slim-swagger
Adding it to Slim is easy too:
$app->add(new \terwey\SlimSwagger(array(), array('baseDir' => __DIR__.'/../src/')));
Where src/
is the directory you keep your API endpoint or Models.
Resources
For now you'll have to grab a release of Swagger-UI and copy /lib
and /css
to your /public
directory.
Also copy over swagger-ui.min.js
to the /public/lib
directory.
Template
I've provided a Twig template in the /templates
directory. Copy this over to your Slim application. If you want to use Twig also install Slim Views.
Docs
The SlimSwagger class takes 2 parameters. The first one is the $swaggerSettings
array, please see the Swagger-PHP docs for more info.
$swaggerSettings = array(
'output' => 'json',
'apiVersion' => $defaultApiVersion,
'swaggerVersion' => $defaultSwaggerVersion,
'defaultSwaggerVersion' => $resourceList['swaggerVersion'],
'defaultBasePath' => $defaultBasePath
);
The second one is the $options
array.
$options = array(
'baseDir' => __DIR__.'/../',
'ignoreDir' => array()
);