I have a .NET Core 2.x project which integrates Swagger and Swashbuckle v4.x. And it all works really well.
However, now I need to append a query string to every GET that is fired by Swagger in the form of www.foo.com/myendpoint?authorization=APIKEY
. To that end, I have the following in Startup.ConfigureServices:
services.AddSwaggerGen(c => {
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
c.AddSecurityDefinition("api key", new ApiKeyScheme() {
Description = "Authorization query string expects API key",
In = "query",
Name = "authorization",
Type = "apiKey"
});
});
When I fire up swagger, it does present me with a dialog box and successfully accepts it when I enter the API key. However, all the API calls still go out without the query string.
What am I missing?
See Question&Answers more detail:os