How can I add Authorize button in swagger, when I have ocelot api gateway?
I configure my service collection like that:
s.AddSwaggerForOcelot(configuration);
s.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "ApiGateway" });
c.AddSecurityDefinition("Bearer",
new OpenApiSecurityScheme
{
In = ParameterLocation.Header,
Description = "Please enter into field the word 'Bearer' following by space and JWT",
Name = "Authorization",
Type = SecuritySchemeType.ApiKey
});
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
}
},
new string[] { }
}
});
c.ExampleFilters();
});
but it doesn't make sense..
You have to add this configuration in all the downstream APIs of your Ocelot API Gateway.
Thus, the securitySchemes
and security
JSON objects will be included to each downstream API Open API Specification.