If my method in my API looks for some custom property that is in the header, ie HttpContext.Current.Request.Headers.Exists("foobar")
, is there a way for me to decorate that method so that Swashbuckle can generate that header for Swagger to test the method with?
I've had good success with decorating with SwaggerResponse
for my methods, to specify return types/codes, but not specifying headers.
I've also been able to add HTTP headers to EVERY request by the way of injecting custom JavaScript:
(function () {
$(function () {
$('#input_apiKey').off();
$('#input_apiKey').on('change', function () {
var key = this.value;
if (key && key.trim() !== '') {
swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("Authorization", key, "header"));
}
});
});
})();
and in SwaggerConfig.cs
:
c.InjectJavaScript(thisAssembly, "Api.CustomContent.jwt-auth.js");