symfony - Nelmio API doc area and bearer token with symfony 4
问题描述
I have API in Symfony 4. I added NelmioApiDocBundle to my project, but i have problem with my docs. This is my configuration: packages\nelmio_api_doc.yaml
nelmio_api_doc:
documentation:
# schemes: [http, https]
info:
title: Symfony JWT API
description: Symfony JWT API docs
version: 1.0.0
securityDefinitions:
Bearer:
type: apiKey
description: 'Authorization: Bearer {jwt}'
name: Authorization
in: header
security:
- Bearer: []
areas: # to filter documented areas
default:
path_patterns:
- ^/api(?!/doc$) # Accepts routes under /api except /api/doc
config\routes.yaml
# Expose your documentation as JSON swagger compliant
app.swagger_ui:
path: /api/doc
methods: GET
defaults: { _controller: nelmio_api_doc.controller.swagger_ui }
I have controller: SpeakerController, HomeController, How can I make each controller a separate area and the rest in default? i.e. SpeakerController in area Speaker, HomeController in area Home etc ..
My next problem is that I have an API protected by a bearer token, when I click Authorize in the swagger, I will add the current jwt token and I want to request it, in response I get:
{
"code": 401,
"message": "JWT Token not found"
}
解决方案
推荐阅读
- javascript - 从数据库到输入的日期时间格式 type='datetime' PHP
- angular - Angular 7:路由到另一个应用程序时如何构建脚本和样式
- spring - 如何在没有代码的情况下从“Spring Tool Suite”可执行文件中共享 Spring MVC 项目?
- javascript - Python/Flask/HTML - 在新窗口而不是主页中呈现 HTML
- java - 如何从多个输入 xml 构建 XML
- c++ - 使用 std::move 将 unique_ptr 移动到向量中
- amazon-web-services - 将域指向 Route 53
- python - VGG16 Tensorflow 实现在 cifar-10 上不学习
- mysql - 如何在 SQL 中将多行合并为一行?
- r - For 循环检索超过 1 个返回值(维数不正确)