Azure / Azure/azure-functions-openapi-extension
Microsoft.Azure.WebJobs.Extensions.OpenApi: OpenApiSecurityAttribute not generating bearer authentication in swagger.json
- Dominant language
- C#
- Stars
- 388
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the issue**
I am using `Microsoft.Azure.WebJobs.Extensions.OpenApi` in my azure function to generate my OpenAPI spec. Unfortunately generating bearer token authentication in the `swagger.json` fails.
Azure function info:
``` xml
net6.0
v4
```
**To Reproduce**
Steps to reproduce the behavior:
1. Add the `OpenApiSecurityAttribute` to the function
```cs
[OpenApiSecurity("bearer_auth", SecuritySchemeType.Http, Scheme = OpenApiSecuritySchemeType.Bearer, BearerFormat = "JWT")]
```
2. Start the function
3. Open the swagger ui
4. Click authenticate
**Expected behavior**
Authentication works in swagger ui, `swagger.json` `securityDefinitions/bearer_auth` is generated.
**Actual behavior**
Error is shown:

On investigation the `swagger.json` `securityDefinitions/bearer_auth` is empty:
```json
{
"securityDefinitions": {
"bearer_auth": {}
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.