Reputation: 68
I need to add specific header on swagger ui using .net core. Is there any way to include header like this?
Already tried:
implementing IOperationFilter:
public void Apply(Operation operation, OperationFilterContext context)
{
if (operation.Parameters == null)
operation.Parameters = new List<IParameter>();
if (operation.Parameters.All(p => p.Name != "Proxy-Authorization"))
{
operation.Parameters.Add(new NonBodyParameter
{
Name = "Proxy-Authorization",
In = "header",
Description = "Proxy-Authorization token",
Required = true,
Type = "string"
});
}
}
adding security definition:
options.AddSecurityDefinition("Proxy-Authorization", new ApiKeyScheme()
{
In = "header",
Description = "Please insert Proxy Authorization Secret into field",
Name = "Proxy-Authorization",
Type = "apiKey"
});
Both didn't work. When I change header name everything work fine, but this specific header is wiped out from a call.
Did you ever meet this issue? How to solve this?
Upvotes: 2
Views: 1124
Reputation: 17594
From: https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name
A forbidden header name is an HTTP header name that cannot be modified programmatically; specifically, an HTTP request header name.
...
Forbidden header names start with Proxy- or Sec-, or consist of one of these:
Upvotes: 2