You can do that using an IOperationFilter
here is a sample code:
public class AddRequiredHeaderParameters : IOperationFilter
{
public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
{
if (operation.operationId == "ValueProvider_Put")
{
if (operation.parameters == null)
operation.parameters = new List<NonBodyParameter>();
operation.parameters.Add(HeaderParam("CID", "101"));
}
}
public IParameter HeaderParam(string name, string defaultValue, bool required = true, string type = "string", string description = "")
{
return new NonBodyParameter
{
Name = name,
In = "header",
Default = defaultValue,
Type = type,
Description = description,
Required = required
};
}
}
I have a working sample here:
https://github.com/heldersepu/SwashbuckleTest/blob/master/Swagger_Test/App_Start/SwaggerConfig.cs#L551
And here is how it looks in the UI:
http://swashbuckletest.azurewebsites.net/swagger/ui/index?filter=ValueProvider#/ValueProvider/ValueProvider_Put