pbaszak/extended-api-doc-bundle

这是一个`nelmio/api-doc-bundle`的扩展,它改进了端点的标签排序,并对原始Nelmio视图进行了轻微的风格修正。

2.0.1 2024-02-14 22:43 UTC

This package is auto-updated.

Last update: 2024-09-14 23:59:45 UTC


README

这是一个`nelmio/api-doc-bundle`的扩展,它改进了端点的标签排序,并对原始Nelmio视图进行了轻微的风格修正。

安装

所需包

composer require symfony/asset
composer require symfony/twig-bundle
composer require nelmio/api-doc-bundle
composer require pbaszak/extended-api-doc-bundle

路由注册

  • /api/doc
  • /api/doc.json
  • /api/doc.yaml
# config/routes.yaml
...
extended_api_doc:
    resource: '@ExtendedApiDocBundle/Resources/routes/*'

设置元信息

# config/packages/nelmio_api_doc.yaml
parameters:
    app_title: '%env(APP_TITLE)%'
    app_description: '%env(APP_DESCRIPTION)%'
    app_version: '%env(APP_VERSION)%'
    app_commit_sha_short: '%env(APP_COMMIT_SHA_SHORT)%'

nelmio_api_doc:
    documentation:
        info:
            title: '%app_title%'
            description: '%app_description%'
            version: '%app_version% (%app_commit_sha_short%)'
    areas: # to filter documented areas
        path_patterns:
            - ^/api(?!/doc(.json|.yaml)?$)

用法

只需在您的服务器上打开/api/doc路径即可享受!

alt text

开发

如何开始

使用以下命令启动本地环境

bash start.sh

如何使用标准版本

如果您没有node_modules目录,请运行

npm install

主要次要修补程序版本更新

npm run version:major
# or
npm run version:minor
# or
npm run version:patch

推送标签

npm run version:release
# or
npm run release

检查package.json以了解命令的作用。

如何使用PHPStan

主要命令

docker exec php composer code:analyse

但是,如果您需要将错误添加到忽略列表中

docker exec php composer code:analyse:b

如何使用PHP CS Fixer

docker exec php composer code:fix

如何在 Visual Studio Code 中使用 XDebug

在您的项目中创建新文件:.vscode/launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for xDebug",
            "type": "php",
            "request": "launch",
            "port": 5902,
            "hostname": "0.0.0.0",
            "pathMappings": {
                "/app/": "${workspaceRoot}"
            }
        }
    ]
}

取消注释.env.local中的环境

XDEBUG_MODE=develop,debug
XDEBUG_CONFIG=" client_port=5902 idekey=VSCODE client_host=host.docker.internal discover_client_host=0 start_with_request=yes"

Ctrl + Shift + D并运行监听xDebug