What is Swagger?
Swagger helps you to describe the structure of APIS that helps machines to read them. It helps to build beautiful and interactive API documentation
Swagger is a set of open-source tools built around the OpenAPI Specification that can help you design, build, document, and consume REST APIs
Laravel Installation
Laravel can be installed using the following command.
composer create-project — prefer-dist laravel/laravel blog
Install Laravel Swagger
composer require “darkaonline/l5-swagger”
If you need old @SWG (SWAGGER annotations) support, install:
composer require ‘zircote/swagger-php:2.*’
Publish the vendor file:
php artisan vendor:publish — provider “L5Swagger\L5SwaggerServiceProvider”
Get the Raw Sample Swagger file from:
Save the file inside the app/Http/Controller as Documentation.php
Update following variables in config/l5-swagger.php
L5_SWAGGER_GENERATE_ALWAYS = true
SWAGGER_VERSION = 2.0
Generate the Swagger JSON File:
php artisan l5-swagger:generate
If everything is fine, api-docs.json file will be generated inside storage/api-docs folder