One of our REST API’s always requires an ‘X-API-Key’ header. To simplify testing, I wanted to have the option to specify the header in the Swagger UI.
Let’s see how we can get this done through SwashBuckle.
First I need to create a custom IOperationFilter that will add the header:
Now we need to update our Swagger configuration to use this header:
If we now run our application and browse to the Swagger UI, we should see the extra header parameter: