多版本控制 URL 在 Swashbuckle.AspNetCore 5.0.0rc 中不起作用
Multiple versioning URL not working in Swashbuckle.AspNetCore 5.0.0rc
多版本控制适用于 Swashbuckle.AspNetCore 4.0.1,但不适用于 5.0.0rc。
现在只有 api-limited-docs
工作 URL 。其他 url 未生成。
- ../api/api-docs --- 不工作
- ../api/api-limitted-docs ---工作
遵循旧代码。
app.UseSwaggerUI(options =>
{
options.RoutePrefix = "api-docs";
string swaggerJsonBasePath = string.IsNullOrWhiteSpace(options.RoutePrefix) ? "." : "..";
options.SwaggerEndpoint($"{swaggerJsonBasePath}/swagger/swagger.json", "v1");
});
app.UseSwaggerUI(options =>
{
options.RoutePrefix = "api-limited-docs";
string swaggerJsonBasePath = string.IsNullOrWhiteSpace(options.RoutePrefix) ? "." : "..";
options.SwaggerEndpoint($"{swaggerJsonBasePath}/swagger/limitted/swagger.json", "v1");
});
是的,最新版本可用。
这是变化。
services.AddSwaggerGen(c =>
{
c.EnableAnnotations();
c.SwaggerDoc("api", new OpenApiInfo { Title = "API - Title", Version = AppClientVersion.LatestVersion});
c.SwaggerDoc("limited", new OpenApiInfo { Title = "limited- Title", Version = AppClientVersion.LatestVersion});
});
多版本控制适用于 Swashbuckle.AspNetCore 4.0.1,但不适用于 5.0.0rc。
现在只有 api-limited-docs
工作 URL 。其他 url 未生成。
- ../api/api-docs --- 不工作
- ../api/api-limitted-docs ---工作
遵循旧代码。
app.UseSwaggerUI(options =>
{
options.RoutePrefix = "api-docs";
string swaggerJsonBasePath = string.IsNullOrWhiteSpace(options.RoutePrefix) ? "." : "..";
options.SwaggerEndpoint($"{swaggerJsonBasePath}/swagger/swagger.json", "v1");
});
app.UseSwaggerUI(options =>
{
options.RoutePrefix = "api-limited-docs";
string swaggerJsonBasePath = string.IsNullOrWhiteSpace(options.RoutePrefix) ? "." : "..";
options.SwaggerEndpoint($"{swaggerJsonBasePath}/swagger/limitted/swagger.json", "v1");
});
是的,最新版本可用。 这是变化。
services.AddSwaggerGen(c =>
{
c.EnableAnnotations();
c.SwaggerDoc("api", new OpenApiInfo { Title = "API - Title", Version = AppClientVersion.LatestVersion});
c.SwaggerDoc("limited", new OpenApiInfo { Title = "limited- Title", Version = AppClientVersion.LatestVersion});
});