What I need basically is a common header passing parameter like the authorization which will send same static value each time in header once added (this value can also be null in my case)
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "SomeTitle", Version = "v1" });
c.OperationFilter<CustomHeaderSwaggerAttribute>();
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
In = ParameterLocation.Header,
Description = "Please insert JWT with Bearer into field",
Name = "Authorization",
Type = SecuritySchemeType.ApiKey
});
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Name = "Bearer",
Type = SecuritySchemeType.ApiKey,
In = ParameterLocation.Header,
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
},
},
new string[] {}
}
});
});
This is my configuration code in which I've currently implemented the CustomHeaderSwaggerAttribute. That is used to get the custom header with every request individually like the picture attached below

