public void EnableSwaggerUi( string routeTemplate, Action <SwaggerUiConfig> configure = null) { var config = new SwaggerUiConfig(_discoveryPaths, _rootUrlResolver); if (configure != null) { configure(config); } _httpConfig.Routes.MapHttpRoute( name: "swagger_ui", routeTemplate: routeTemplate, defaults: null, constraints: new { assetPath = @".+" }, handler: new SwaggerUiHandler(config) ); if (routeTemplate == DefaultRouteTemplate) { _httpConfig.Routes.MapHttpRoute( name: "swagger_ui_shortcut", routeTemplate: "swagger", defaults: null, constraints: null, handler: new RedirectHandler(_rootUrlResolver, "swagger/ui/index")); } }
public void EnableSwaggerUi( string routeTemplate, Action<SwaggerUiConfig> configure = null) { var config = new SwaggerUiConfig(_discoveryPaths, _rootUrlResolver); if (configure != null) configure(config); _httpConfig.Routes.MapHttpRoute( name: "swagger_ui", routeTemplate: routeTemplate, defaults: null, constraints: new { assetPath = @".+" }, handler: new SwaggerUiHandler(config) ); if (routeTemplate == DefaultRouteTemplate) { _httpConfig.Routes.MapHttpRoute( name: "swagger_ui_shortcut", routeTemplate: "swagger", defaults: null, constraints: new { uriResolution = new HttpRouteDirectionConstraint(HttpRouteDirection.UriResolution) }, handler: new RedirectHandler(_rootUrlResolver, "swagger/ui/index")); } }
public static SwaggerUiConfig MobileAppUi(this SwaggerUiConfig config) { if (config == null) { throw new ArgumentNullException("config"); } Assembly thisAssembly = typeof(SwaggerUiConfigExtensions).Assembly; config.CustomAsset("o2c-html", thisAssembly, "Microsoft.Azure.Mobile.Server.Swagger.o2c.html"); config.CustomAsset("lib/swagger-oauth-js", thisAssembly, "Microsoft.Azure.Mobile.Server.Swagger.swagger-oauth.js"); return(config); }
public void EnableSwaggerUi(string routeTemplate, Action <SwaggerUiConfig> configure = null) { var config = new SwaggerUiConfig(_discoveryPaths, _rootUrlResolver); if (configure != null) { configure(config); } if (!string.IsNullOrWhiteSpace(config.RoutePrefix)) { routeTemplate = config.RoutePrefix + "/" + routeTemplate; } _httpConfig.Routes.MapHttpRoute( name: "swagger_ui" + routeTemplate, routeTemplate: routeTemplate, defaults: null, constraints: new { assetPath = @".+" }, handler: new SwaggerUiHandler(config)); if (routeTemplate == DefaultRouteTemplate) { _httpConfig.Routes.MapHttpRoute( name: "swagger_ui_shortcut", routeTemplate: "swagger", defaults: null, constraints: new { uriResolution = new HttpRouteDirectionConstraint(HttpRouteDirection.UriResolution) }, handler: new RedirectHandler(_rootUrlResolver, "swagger/ui/index")); } if (routeTemplate == config.RoutePrefix + "/" + DefaultRouteTemplate) { _httpConfig.Routes.MapHttpRoute( name: "swagger_ui_shortcut" + routeTemplate, routeTemplate: config.RoutePrefix + "/" + "swagger", defaults: null, constraints: new { uriResolution = new HttpRouteDirectionConstraint(HttpRouteDirection.UriResolution) }, handler: new RedirectHandler(_rootUrlResolver, config.RoutePrefix + "/" + "swagger/ui/index")); } }
public void EnableSwaggerUi(string routeTemplate, Action <SwaggerUiConfig> configure = null) { SwaggerUiConfig config = new SwaggerUiConfig(this._discoveryPaths, this._rootUrlResolver); if (configure != null) { configure(config); } HttpRouteCollectionExtensions.MapHttpRoute(this._httpConfig.get_Routes(), "swagger_ui" + routeTemplate, routeTemplate, (object)null, (object)new { assetPath = ".+" }, (HttpMessageHandler) new SwaggerUiHandler(config)); if (!(routeTemplate == SwaggerEnabledConfiguration.DefaultRouteTemplate)) { return; } HttpRouteCollectionExtensions.MapHttpRoute(this._httpConfig.get_Routes(), "swagger_ui_shortcut", "swagger", (object)null, (object)new { uriResolution = new HttpRouteDirectionConstraint((HttpRouteDirection)0) }, (HttpMessageHandler) new RedirectHandler(this._rootUrlResolver, "swagger/ui/index")); }
public static SwaggerUiConfig MobileAppUi(this SwaggerUiConfig config, HttpConfiguration httpConfig) { if (config == null) { throw new ArgumentNullException("config"); } if (httpConfig == null) { throw new ArgumentNullException("httpConfig"); } httpConfig.MessageHandlers.Add(new SwaggerUiSecurityFilter(httpConfig)); Assembly thisAssembly = typeof(SwaggerUiConfigExtensions).Assembly; config.CustomAsset("o2c-html", thisAssembly, "Microsoft.Azure.Mobile.Server.Swagger.o2c.html"); config.CustomAsset("swagger-ui-min-js", thisAssembly, "Microsoft.Azure.Mobile.Server.Swagger.swagger-ui.min.js"); config.CustomAsset("index", thisAssembly, "Microsoft.Azure.Mobile.Server.Swagger.index.html"); return(config); }
public void EnableSwaggerUi( string areaRouteTemplate, Action <SwaggerUiConfig> configure = null) { foreach (var area in _areasDiscoveryPaths.Keys) { var routeTemplate = areaRouteTemplate.Replace("{area}", area.Name.ToLowerInvariant()); var configurationContext = _areasDiscoveryPaths[area]; var config = new SwaggerUiConfig(configurationContext.DiscoveryPaths, configurationContext.RootUrlResolver); configure?.Invoke(config); _httpConfig.Routes.MapHttpRoute( name: "swagger_ui" + routeTemplate, routeTemplate: routeTemplate, defaults: null, constraints: new { assetPath = @".+" }, handler: new SwaggerUiHandler(config) ); if (routeTemplate == DefaultRouteTemplate) { _httpConfig.Routes.MapHttpRoute( name: "swagger_ui_shortcut", routeTemplate: "swagger", defaults: null, constraints: new { uriResolution = new HttpRouteDirectionConstraint(HttpRouteDirection.UriResolution) }, handler: new RedirectHandler(configurationContext.RootUrlResolver, "swagger/ui/index")); } } var swaggerEnabledConfiguration = new SwaggerEnabledConfiguration(_httpConfig, _noAreaConfigurationContext.RootUrlResolver, _noAreaConfigurationContext.DiscoveryPaths); var noAreaRouteTemplate = areaRouteTemplate.Replace("{area}/", string.Empty); swaggerEnabledConfiguration.EnableSwaggerUi(noAreaRouteTemplate, configure); }
public SwaggerUiHandler(SwaggerSpecConfig swaggerSpecConfig, SwaggerUiConfig config) { _swaggerSpecConfig = swaggerSpecConfig; _swaggerUiConfig = config; }
public SwaggerUiHandler(SwaggerUiConfig config) { _config = config; }
public SwaggerUiHandler() { _config = SwaggerUiConfig.StaticInstance; }
public SwaggerUiHandler() : this(SwaggerUiConfig.StaticInstance) { _config = SwaggerUiConfig.StaticInstance; }
public void EnableSwaggerUi(string routeTemplate, Action<SwaggerUiConfig> configure = null) { var config = new SwaggerUiConfig(_discoveryPaths, _rootUrlResolver); if (configure != null) configure(config); var apiKey = _swaggerDocsConfig.GetApiKeyDetails(); if (apiKey != null) { config.SetApiKeyDetails(apiKey); } _httpConfig.Routes.MapHttpRoute( name: "swagger_ui", routeTemplate: routeTemplate, defaults: null, constraints: new { assetPath = @".+" }, handler: new SwaggerUiHandler(config) ); if (routeTemplate == DefaultRouteTemplate) { _httpConfig.Routes.MapHttpRoute( name: "swagger_ui_shortcut", routeTemplate: "swagger", defaults: null, constraints: null, handler: new RedirectHandler(_rootUrlResolver, "swagger/ui/index")); } }