0

次のようにインストールを開始しました:
https://symfony.com/doc/4.x/bundles/NelmioApiDocBundle/index.html
ステップ 1.

`composer require nelmio/api-doc-bundle` - Thats OK

ステップ2。

    class AppKernel extends Kernel
    {
        public function registerBundles()
        {
                $bundles = [
                    new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
                ];
        }
    }

しかし、カーネルを拡張する AppKernel はありません。
`$contents = require $this->getProjectDir().'/config/bundles.php';`を使用して **カーネル** を持っている
ので、**/config/bundles.php** に追加しました。
Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['all' => true],

ステップ 3. config/routes.yaml
に追加しました

# config/routes.yaml
app.swagger_ui:
    path: /api/doc
    methods: GET
    defaults: { _controller: nelmio_api_doc.controller.swagger_ui }

ステップ 4. config/packages/nelmio_api_doc.yaml
作成しました

nelmio_api_doc:
    areas:
        path_patterns: # an array of regexps
            - ^/api(?!/doc$)
        host_patterns:
            - ^api\.

その後、mysite/api/doc に Swagger のページが表示されるはずです
が、github にリンク 'NelmioApiDocBundle' のある白いページしか表示され
ません。

4

2 に答える 2

0

nelmio_api_docで領域を指定する必要があります

nelmio_api_doc:
    documentation:
        info:
            title: My App
            description: This is an awesome app!
            version: 1.0.0
    areas: # to filter documented areas
        path_patterns:
            - ^/api(?!/doc$) # Accepts routes under /api except /api/doc
            - ^/secured/project(?!/doc$) # Accepts routes under /api except /api/doc

于 2021-03-23T21:43:36.467 に答える