liaosp/think-swagger

thinkphp apidoc gen think-swagger swaggerv3

v1.0.2 2021-09-16 10:06 UTC

This package is auto-updated.

Last update: 2024-09-16 20:35:13 UTC


README

thinkphp5 自动生成swagger文档 swagger-ui

Latest Stable Version Total Downloads Daily Downloads License StyleCI

TP6 后续发布

安装

$ composer require liaosp/think-swagger -vvv

使用方法

安装完成后,在application 下的任意文件写入:

     /**
      * @OA\Info(
      *      version="1.0.0",
      *      title="OpenApi",
      *      description="Swagger OpenApi description",
      *      @OA\Contact(
      *          email="darius@matulionis.lt"
      *      ),
      *     @OA\License(
      *         name="Apache 2.0",
      *         url="https://apache.ac.cn/licenses/LICENSE-2.0.html"
      *     )
      * )
      */
 
     /**
      * @OA\Get(
      *      path="/projects/{id}",
      *      operationId="getProjectById",
      *      tags={"Projects"},
      *      summary="Get project information",
      *      description="Returns project data",
      *      @OA\Parameter(
      *          name="id",
      *          description="Project id",
      *          required=true,
      *          in="path",
      *          @OA\Schema(
      *              type="integer"
      *          )
      *      ),
      *      @OA\Response(
      *          response=200,
      *          description="successful operation"
      *       ),
      *      @OA\Response(response=400, description="Bad request"),
      *      @OA\Response(response=404, description="Resource Not Found"),
      *      security={
      *         {
      *             "oauth2_security_example": {"write:projects", "read:projects"}
      *         }
      *     },
      * )
      */

访问:

你的域名/apidoc

如果你想扫描指定的文件目录,在config/app.php 添加绝对路径

'swagger_path' =>'绝对路径 __DIR__ 自定义'

更多用法可参考我之前写的博客相关

swagger 使用

如何写composer包

如何写这个包

贡献

你可以通过以下三种方式之一进行贡献

  1. 使用 问题跟踪器 提交错误报告。
  2. 问题跟踪器 上回答问题或修复错误。
  3. 贡献新功能或更新wiki。

代码贡献过程并不非常正式。你只需确保遵循PSR-0、PSR-1和PSR-2编码规范。任何新的代码贡献都必须附有适用的单元测试。

许可证

MIT