liaosp / think-swagger
thinkphp apidoc gen think-swagger swaggerv3
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/liaosp/think-swagger
Requires
- zircote/swagger-php: ^3.2
 
This package is auto-updated.
Last update: 2025-10-16 23:05:48 UTC
README
thinkphp5 自动生成swagger文档 swagger-ui
TP6 后续发布
Installing
$ composer require liaosp/think-swagger -vvv
Usage
安装好后,在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="http://www.apache.org/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__ 自定义'
更多用法可参考我之前写的博客相关
Contributing
You can contribute in one of three ways:
- File bug reports using the issue tracker.
 - Answer questions or fix bugs on the issue tracker.
 - Contribute new features or update the wiki.
 
The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.
License
MIT

