Though this post is old, I thought it would help new comers if they get stuck
in the same situation.
public class AddRequiredHeaderParameter : IOperationFilter
{
public void Apply(Operation operation, SchemaRegistry schemaRegistry,
ApiDescription apiDescription)
{
if (operation.parameters == null)
{
operation.parameters = new List<Parameter>();
}
/*System.Diagnostics.Trace.WriteLine(apiDescription.RelativePath +
"=paath");*/
if (apiDescription.RelativePath.Contains(***{url***}))
{
operation.parameters.Add(new Parameter
{
name = "X-User-Token",
@in = "header",
type = "string",
required = false,
description=""
});
operation.parameters.Add(new Parameter
{
name = "authorization",
@in = "header",
description = "Token",
type = "string",
required = true
});
}
else
{
operation.parameters.Add(new Parameter
{
name = "X-User-Token",
@in = "header",
type = "string",
required = false,
description="description"
});
}
}
}