0

I started to install like this:
https://symfony.com/doc/4.x/bundles/NelmioApiDocBundle/index.html
Step 1.

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

Step 2.

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

But I have no AppKernel extends Kernel. I **just have Kernel** with
`$contents = require $this->getProjectDir().'/config/bundles.php';`
So I added into **/config/bundles.php**
Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['all' => true],

Step 3.
I added into config/routes.yaml

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

Step 4.
I created config/packages/nelmio_api_doc.yaml with

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

After that I should see Swagger's page at mysite/api/doc
But i see only white page with link 'NelmioApiDocBundle' at github
What I did wrong?

Helen
  • 87,344
  • 17
  • 243
  • 314
Den
  • 19
  • 1
  • 6
  • Have you added annotations to your routes as written in this section? https://symfony.com/doc/4.x/bundles/NelmioApiDocBundle/index.html#using-the-bundle – R A Feb 04 '21 at 09:28
  • > Have you added annotations to your routes as written in this section? Yes It didnt change anything And as far as I understood, Step 3 enouth for swagger start page – Den Feb 04 '21 at 18:07
  • In a couple of days it started to work wothout new changes. I dont know why... – Den Feb 11 '21 at 17:37
  • It might be that a cache in var/cache was cleared. – R A Feb 11 '21 at 20:55
  • @RA I cleared it before a lot of times – Den Feb 12 '21 at 16:52
  • Hey i have the same problem. How did you fix it ? – roibubble Mar 23 '21 at 14:41

2 Answers2

0

I ran:

bin/console assets:install --symlink

and it's now working.

roibubble
  • 125
  • 3
  • 8
0

You need to specify areas in your 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

L3xpert
  • 1,109
  • 1
  • 10
  • 19