Der SwaggerUiHeaderBuilder erstellt einen Spezial-Header für das Swagger Ui
public class SwaggerUiHeaderBuilder
{
ISwaggerUiHeaderBuilder AddCustomLink(string caption, Uri href);
ISwaggerUiHeaderBuilder UseConfig(ISwaggerUiCustomHeaderConfig value);
ISwaggerUiHeaderBuilder ForHeaderBgColor(string value);
ISwaggerUiHeaderBuilder ForHeaderFontColor(string value);
ISwaggerUiHeaderBuilder ForHoverBgColor(string value);
ISwaggerUiHeaderBuilder ForHoverFontColor(string value);
ISwaggerUiHeaderBuilder ForImageSrc(string value);
ISwaggerUiHeaderBuilder ForTitel(string value);
ISwaggerUiHeaderBuilder ForVersion(string value);
string Build();
}
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "MyApi V1");
c.UseCustomHeader(header => header
.ForTitel("MyTestTitel")
.ForVersion("v1.0.0.1")
.AddCustomLink("MyCustomLink1", new Uri("https://myCutom1.url"))
.AddCustomLink("MyCustomLink2", new Uri("https://myCutom2.url"))
.ForHeaderBgColor("#fff9f3")
.ForHoverBgColor("#d66b00")
.ForHeaderFontColor("black"));
});
}
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "MyApi V1");
c.HeadContent = new SwaggerUiHeaderBuilder()
.ForTitel("MyTestTitel")
.ForVersion("v1.0.0.1")
.AddCustomLink("MyCustomLink1", new System.Uri("https://myCutom1.url"))
.AddCustomLink("MyCustomLink2", new System.Uri("https://myCutom2.url"))
.ForHeaderBgColor("#fff9f3")
.ForHoverBgColor("#d66b00")
.ForHeaderFontColor("black")
.Build();
});
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "MyApi V1");
//Example 3
c.UseCustomHeader(header => header
.UseConfig(_swaggerUiCustomHeaderConfig)
.AddCustomLink("MyCustomLink1", new Uri("https://myCutom1.url"))
.AddCustomLink("MyCustomLink2", new Uri("https://myCutom2.url")));
});