public static ITunnelBuilder UseNGrok(this ITunnelBuilder builder, string tunnelApiUrl = "http://localhost:4040/api/tunnels") { var nswagTunnelRootUrl = string.Empty; using (var nswagApiClient = new HttpClient()) { var json = nswagApiClient.GetStringAsync(tunnelApiUrl).Result; var ngrokTunnelResponse = JsonSerializer.Deserialize <NGrokTunnelApiResponse>(json); var tunnel = ngrokTunnelResponse.Tunnels.FirstOrDefault(x => x.Protocol == "https") ?? ngrokTunnelResponse.Tunnels.First(); builder.WithRootUrl(tunnel.PublicUrl); } return(builder); }
public static ITunnelBuilderThatHasAnOpenApiDocumentEndpoint UseSwashbuckleOpenApiEndpoint( this ITunnelBuilder tunnelBuilder, Action <ITunnelBuilderThatHasAnOpenApiDocumentEndpoint> buildTunnel = null) { var swaggerOptions = tunnelBuilder.Host.Services.GetService <IOptions <SwaggerOptions> >(); var docTemplate = swaggerOptions.Value.RouteTemplate; var swaggerGenOptions = tunnelBuilder.Host.Services.GetService <IOptions <SwaggerGeneratorOptions> >(); var openApiDoc = swaggerGenOptions.Value.SwaggerDocs.First(); var version = openApiDoc.Value.Version; var swaggerEndpoint = docTemplate.Replace("{documentName}", openApiDoc.Key); var result = new SwashbuckleGeneratedOpenApiTunnelBuilder(tunnelBuilder) { OpenApiDocumentEndpoint = swaggerEndpoint, Version = version }; buildTunnel?.Invoke(result); return(result); }
public SwashbuckleGeneratedOpenApiTunnelBuilder(ITunnelBuilder tunnelBuilder) { _tunnelBuilder = tunnelBuilder; }