protected override Task <HttpResponseMessage> SendAsync( HttpRequestMessage request, CancellationToken cancellationToken) { IAssetProvider swaggerUiProvider = this._config.GetSwaggerUiProvider(); string rootUrl = this._config.GetRootUrl(request); string assetPath = HttpRequestMessageExtensions.GetRouteData(request).get_Values()["assetPath"].ToString(); try { HttpContent httpContent = this.ContentFor(swaggerUiProvider.GetAsset(rootUrl, assetPath)); return(this.TaskFor(new HttpResponseMessage() { Content = httpContent, RequestMessage = request })); } catch (AssetNotFound ex) { return(this.TaskFor(HttpRequestMessageExtensions.CreateErrorResponse(request, HttpStatusCode.NotFound, (Exception)ex))); } }
protected override Task <HttpResponseMessage> SendAsync( HttpRequestMessage request, CancellationToken cancellationToken) { ISwaggerProvider swaggerProvider = this._config.GetSwaggerProvider(request); string rootUrl = this._config.GetRootUrl(request); string apiVersion = HttpRequestMessageExtensions.GetRouteData(request).get_Values()["apiVersion"].ToString(); try { SwaggerDocument swagger = swaggerProvider.GetSwagger(rootUrl, apiVersion); HttpContent httpContent = this.ContentFor(request, swagger); return(this.TaskFor(new HttpResponseMessage() { Content = httpContent })); } catch (UnknownApiVersion ex) { return(this.TaskFor(HttpRequestMessageExtensions.CreateErrorResponse(request, HttpStatusCode.NotFound, (Exception)ex))); } }