i'm working on dotnet core web api back end application and using swagger for endpoints documentation.
i want to customize swagger.json endpoint to diffrent path so it could be accessible in our server and our angular fornt-end could consume that endpoint after deloy.
i'm using this code in startup.cs
in ConfigureServices
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Criistal API v1.0", Version = "v1.0" });
/////////////////////
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description ="JWT Authorization header using the Bearer scheme.
Enter 'Bearer' [space] and then your token in the text input below.
Example: "Bearer 12345abcdef"",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey,
Scheme = "Bearer"
});
c.AddSecurityRequirement(new OpenApiSecurityRequirement()
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
},
Scheme = "oauth2",
Name = "Bearer",
In = ParameterLocation.Header,
},
new List<string>()
}
});
////////////////////
});
and in configure
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Criistal API v1.0");
c.RoutePrefix = string.Empty;
});
question from:
https://stackoverflow.com/questions/65934585/dotnet-core-3-1-swagger-documentation 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…