How to integrate swagger into lumen / laravel to relax api?

I built some rest api in the microprogram of the lumen and its operability, now I want to integrate the insert into it so that the api will document future use well. Has anyone done this? Any help would be appreciated.

+4
source share
1 answer

It was very difficult for me to learn to use it. Here I am going to share some things that I have done to make it work.

Use this wrapper

Run this command in terminal:

composer require "darkaonline/swagger-lume:5.5.*"

Or an older version from the repo link if this does not work for you

Then from the repo follow these steps:

bootstrap/app.php : ( 26) " " :

 $app->withFacades(); add this line before Register Container Bindings section:

 $app->configure('swagger-lume'); add this line in Register Service Providers section:

$app->register(\SwaggerLume\ServiceProvider::class);

YAML JSON ... Annotation.php ,

/**
 * @SWG\Swagger(
 *     basePath="/",
 *     schemes={"http"},
 *     @SWG\Info(
 *         version="1.0.0",
 *         title="HAVE MY BOOKS",
 *         @SWG\Contact(
 *             email="ishumahajan94@gmail.com"
 *         ),
 *     )
 * )
 */
/**
* @SWG\Get(
 *   path="/",
 *   summary="Version",
 *   @SWG\Response(
 *     response=200,
 *     description="Working"
 *   ),
 *   @SWG\Response(
 *     response="default",
 *     description="an ""unexpected"" error"
 *   )
 * )
 */

php artisan swagger-lume:publish

php artisan swagger-lume:generate

JSON, : 8000 , LUMEN

: ,

php -S localhost:8000 public/index.php

- PHP php -S localhost:8000 pulic

0

Source: https://habr.com/ru/post/1681857/


All Articles