Using ApiKeyScheme doesn't give me the ability to specify the API key for authorization on the UI. Not sure if it did, or is supposed to (this is my first time using Swagger and Swashbuckle/Ahoy)
version 6.0.0-beta901
Alright, so I've done some testing and it seems that Swagger UI 2.1.4 (which is bundled with Ahoy) doesn't show the authorization UI for ApiKeyScheme. However, the master branch does; any change we could get a release with an updated (prerelease) Swagger UI?
I had a similar issue. I was able to see the "Authorize" button in the UI menu, but when I clicked on api key in the popup nothing happened. My issue was that I had to specify the "Type" as "apiKey".... not sure if your issue is related. Not sure why "type" can't be inferred by the ApiKeyScheme class.
services.AddSwaggerGen(options =>
{
options.SingleApiVersion(new Swashbuckle.Swagger.Model.Info()
{
TermsOfService = "Copyright, " + DateTime.Now.Year.ToString() + " My Company, Inc. All Rights Reserved. For authorized use only.",
Description = "For authorized use only.",
Version = "v1",
Contact = new Swashbuckle.Swagger.Model.Contact()
{
Email = "myemail.... omitted",
Name = "Chris Klepeis"
},
Title = "My Services"
});
options.IncludeXmlComments(String.Format(@"{0}\SO.WebServices.XML", AppDomain.CurrentDomain.BaseDirectory)); // Use xml comments for Swagger documentation
options.AddSecurityDefinition("Bearer", new ApiKeyScheme()
{
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
Name = "Authorization",
In = "header",
Type = "apiKey"
});
});
This should be available with the latest preview packages available on myget:
Available with latest pre-release. Note the package rename to "Swashbuckle.AspNetCore.1.0.0-rc1"
Most helpful comment
I had a similar issue. I was able to see the "Authorize" button in the UI menu, but when I clicked on api key in the popup nothing happened. My issue was that I had to specify the "Type" as "apiKey".... not sure if your issue is related. Not sure why "type" can't be inferred by the ApiKeyScheme class.