PHP code example of sadi01 / yii2-swagger
1. Go to this page and download the library: Download sadi01/yii2-swagger library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sadi01 / yii2-swagger example snippets
'modules' => [
...
'swagger' => [
'class' => \sadi01\swagger\Module::class,
// 'url' => 'http://petstore.swagger.io/v2/swagger.json',
'path' => '@frontend/modules/api',
// disable page with your logic
'isDisable' => function () {
return false;
},
// replace placeholders in swagger content
'afterRender' => function ($content) {
$content = str_replace('{{host}}', 'http://example.com', $content);
$content = str_replace('{{basePath}}', '/api/v1', $content);
return $content;
}
]
...
],
/**
* Class Module Api
*
*
* @SWG\Swagger(
* basePath="{{basePath}}",
* host="{{host}}",
* schemes={"http"},
* @SWG\Info(
* version="1.0",
* title="Example API",
* @SWG\Contact(name="Example", url="http://example.ru"),
* ),
* @SWG\Definition(
* definition="Error",
*
/**
* @SWG\Post(
* path = "/user-device/register",
* tags = {"user-device"},
* operationId = "userDevice",
* summary = "Регистрация устройства",
* description = "Регистрация устройства",
* produces = {"application/json"},
* consumes = {"application/json"},
* @SWG\Parameter(
* in = "body",
* name = "body",
* description = "Тело запроса",
*
/**
* @SWG\Definition(
* definition="UserDeviceForm",
* ="string",
* description="UUID устройства",
* example="e3243"
* ),
* @SWG\Property(
* property="token",
* type="string",
* description="token для Google Fire Base",
* example="e3243"
* ),
* @SWG\Property(
* property="os",
* type="string",
* description="os устройства android|ios",
* example="ios"
* ),
* @SWG\Property(
* property="json",
* type="string",
* description="json достпные параметры устройства, название модели, версия ОС и др",
* example=""
* )
* )
*/
php composer.phar