v.0.0.9-beta
Pre-release
Pre-release
MbSoftLab.SwaggerUiHeaderBuilder
Updates
- Added Support for Using SwaggerUI Header Config
- Extracted Interfaces for SwaggerUiCustomHeaderConfig and SwaggerUiHeaderBuilder
- Added new examples for using the Builder in Readme and DemoProject
- Added DemoProject with example for getting SwaggUiHeaderConfig from appsettings.json
QuickStart
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();
}
Beispiele:
Beispiel 1
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"));
});
}
Beispiel 2
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();
});
Beispiel 3
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")));
});