1

我尝试将 nelmio/api-doc-bundle 配置为将 Authorization 标头用于我的 Bearer 令牌。

nelmio_api_doc.yaml像这样配置它

nelmio_api_doc:
    documentation:
        info:
            title: title
            version: 1.0.0
        securityDefinitions:
            Bearer:
                type: apiKey
                description: 'jwt from oauth prefixed by `Bearer`'
                name: Authorization
                in: header
        security:
            -   Bearer: []
    areas: # to filter documented areas
        path_patterns:
            - ^/api(?!/doc$|/doc.json$) # Accepts routes under /api except /api/doc and /api/doc.json

但是当我到达 ui doc 页面时,我得到了:

注意:未定义索引:securityDefinitions

有人知道如何解决吗?

4

1 回答 1

2

它在第 4 版中已更改,请查看此文档https://symfony.com/doc/4.x/bundles/NelmioApiDocBundle/index.html#using-the-bundle

于 2020-11-23T14:59:54.433 回答