public CustomSwaggerMiddleware(
     RequestDelegate next,
     IHostingEnvironment env,
     CustomSwaggerMiddlewareOpts opts
     )
 {
     _env             = env;
     _next            = next;
     _opts            = opts;
     _requestMatcher  = new TemplateMatcher(TemplateParser.Parse(_opts.baseRoute), new RouteValueDictionary());
     _swaggerAssembly = typeof(SwaggerUiMiddleware).GetTypeInfo().Assembly;
 }
        public static IApplicationBuilder UseCustomSwaggerUi(this IApplicationBuilder app,
                                                             CustomSwaggerMiddlewareOpts opts)
        {
            var baseRoute = opts.baseRoute.Trim('/');

            app.UseMiddleware <CustomSwaggerMiddleware>(new object[] {
                opts
            });

            // Serve all other swagger-ui assets as static files
            var options = new FileServerOptions();

            options.RequestPath        = "/" + baseRoute;
            options.EnableDefaultFiles = false;
            options.StaticFileOptions.ContentTypeProvider = new FileExtensionContentTypeProvider();
            options.FileProvider = new EmbeddedFileProvider(typeof(SwaggerUiBuilderExtensions).GetTypeInfo().Assembly,
                                                            "Swashbuckle.SwaggerUi.bower_components.swagger_ui.dist");
            app.UseFileServer(options);
            return(app);
        }