php-autogen/swagger

基于swagger的API自动文档生成器

1.1.9 2023-06-06 19:55 UTC

This package is auto-updated.

Last update: 2024-09-06 22:42:23 UTC


README

使用darkaonline/l5-swagger库进行API自动文档生成的生成器

要求

https://github.com/DarkaOnLine/L5-Swagger/wiki/Installation-%26-Configuration

安装

composer require php-autogen/swagger

使用方法

步骤01

No framework Laravel rode o comando:

php artisan gen-swagger-doc

步骤02

As "Rules" das "Actions" ou "Controllers" devem seguir o mesmo padrão para que funcione com exito:

    public function rules()
    {
        return [
            'password' => 'required',
            'email'      => 'required|string'
        ];
    }

步骤03

步骤04

 Adicione a seguinte anotação "INFO" dentro de alguma anotação criada automaticamente

* @OA\Info(title="API DOCUMENTATION", version="0.1")
*
* @OA\SecurityScheme(
*     securityScheme="bearerAuth",
*     type="http",
*     scheme="bearer",
*     bearerFormat="JWT"
* ),
*
* @OA\Security(
*     security={{"bearerAuth": {}}}
* )
*

EXEMPLO:
/**
*
* @OA\Info(title="API DOCUMENTATION", version="0.1")
*
* @OA\SecurityScheme(
*     securityScheme="bearerAuth",
*     type="http",
*     scheme="bearer",
*     bearerFormat="JWT"
* ),
*
* @OA\Security(
*     security={{"bearerAuth": {}}}
* )
*
* @OA\Post(
*     path="/auth",
*     summary="Authenticate",
*     tags={"auth"},
*
*         @OA\RequestBody(
*         required=true,
*         @OA\JsonContent(
*             @OA\Property(property="password", type="required"),
*             @OA\Property(property="cpf", type="required"),
*
*         )
*     ),
*     @OA\Response(
*         response="201 - Authenticate",
*         description="Successful operation",
*     ),
*     security={{"bearerAuth": {}}},
* ),
*/