Class SwaggerHandler
Handler to enable Swagger. Configuration is read from the appsettings.json file.
Inheritance
Inherited Members
Namespace: Celerik.NetCore.Web
Assembly: cs.temp.dll.dll
Syntax
public static class SwaggerHandler
Examples
appsettings.json: "Swagger": { "ApiName": "My Awesome API", "ApiVersion": "1.0", "IsEnabled": true, "JsonEndpoint": "/swagger/v1/swagger.json" }
Methods
AddSwagger(IServiceCollection, IConfiguration, ILogger)
Adds Swagger services to this IServiceCollection.
By convention, Swagger configuration properties are get from the IConfiguration object in the following way:
- IsEnabled: Swagger:IsEnabled
- ApiVersion: Swagger:ApiVersion
- ApiName: Swagger:ApiName
- JsonEndpoint: Swagger:JsonEndpoint
Declaration
public static void AddSwagger(this IServiceCollection services, IConfiguration config, ILogger logSvc)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | The IServiceCollection to add services to. |
IConfiguration | config | Object to access application configuration properties. |
ILogger | logSvc | Reference to the current ILogService instance. |
UseSwagger(IApplicationBuilder, IConfiguration, ILogger)
Use Swagger in case it is enabled from the appsettings.json file.
By convention, Swagger configuration properties are get from the IConfiguration object in the following way:
- IsEnabled: Swagger:IsEnabled
- ApiVersion: Swagger:ApiVersion
- ApiName: Swagger:ApiName
- JsonEndpoint: Swagger:JsonEndpoint
Declaration
public static void UseSwagger(this IApplicationBuilder app, IConfiguration config, ILogger logSvc)
Parameters
Type | Name | Description |
---|---|---|
IApplicationBuilder | app | Object to configure the application's request pipeline. |
IConfiguration | config | Object to access application configuration properties. |
ILogger | logSvc | Reference to the current ILogService instance. |