when I check on swagger , my path "/customers" says "no headers authorization" whereas I have entered a Bearer token into the top right "Authorize" input. It is like the customers "security" prop is not linked to general securityDefinitions. In web Swagger, the padlock near GET /Customers is grey and open, when I click on it it does not show any "available authorization".(Postman version is working), I can't find why, could you help me please ?
In my swagger-ui (2.0)json file I got :
"securityDefinitions": {
"Bearer": {
"type": "apiKey",
"name": "Authorization",
"in": "header",
"description": "Enter your bearer token in the format **Bearer <token>**"
}
},
then below on the second path I entered "security" :
"/customers": {
"get": {
"tags": ["Customer Search"],
"summary": "find a customer by email, name, tel, ...",
"security": [{ "bearerAuth": [] }],
"parameters": [
{
"name": "email",
"in": "query",
"description": "email",
"required": true,
"type": "string"
},
{
"name": "realmCode",
"in": "query",
"description": "realmCode",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "send customer json file"
}
}
Here is the beginning of my node Express JS code for my route :
router.get("/customers", async (req: any, res: any) => {
if (!req.headers.authorization)
return res.status(401).json({ error: "no headers authorization" });
else {
```
OK I found it :
"security": [{ "Bearer": [] }],
instead of "bearerAuth" :)