2
votes

I created a webapi on asp.net core and for the documentation I am using swagger swashbuckl.

My API need's some custom headers to validate request along with jwt-token

I need this custom headers

orgid: fe5mp0 brnid: NY0023 Authorization: Bearer

I managed to add Authorization header and it is working but can't find how to add these custom headers.

1

1 Answers

3
votes

The official explanation is here

https://github.com/domaindrivendev/Swashbuckle/issues/501#issuecomment-143254123

public class AddRequiredHeaderParameter : IOperationFilter
{
    public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
    {
        if (operation.parameters == null)
            operation.parameters = new List<Parameter>();

        operation.parameters.Add(new Parameter
            {
                name = "Foo-Header",
                @in = "header",
                type = "string",
                required = true
            });
    }
}