PHP code example of riconijeboer / laravel-to-swagger
1. Go to this page and download the library: Download riconijeboer/laravel-to-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/ */
riconijeboer / laravel-to-swagger example snippets
/**
* Register any application services.
*
* @return void
*/
public function register()
{
if ($this->app->environment('local')) {
$this->app->register(\RicoNijeboer\Swagger\SwaggerServiceProvider::class);
}
}
use RicoNijeboer\Swagger\Swagger;
Swagger::routes();
use RicoNijeboer\Swagger\Http\Routing\RouteRegistrar;
use RicoNijeboer\Swagger\Swagger;
Swagger::routes(fn (RouteRegistrar $routes) => $routes->forDocumentation('/different-url/docs'));
use RicoNijeboer\Swagger\Swagger;
Swagger::routes(null, [
'prefix' => 'swagger', // This will do Route::group(['prefix' => 'swagger']) under the hood.
]);
use RicoNijeboer\Swagger\Http\Routing\RouteRegistrar;
use RicoNijeboer\Swagger\Swagger;
Swagger::routes(fn (RouteRegistrar $routes) => $routes->forDocumentation('/docs', false));
// Using the SwaggerReader middleware
Route::middleware('swagger_reader:tag-one,tag-two')->get('products', [ProductController::class,'index']);
// Using the SwaggerTag middleware
Route::middleware('swagger_tag:tag-one,tag-two')->get('products', [ProductController::class,'index']);