>
>
> I have written a netcore middleware to log request and its response in my 
> netcore service layer.
> It uses the following workaround and performs quite well:
>
> http://stackoverflow.com/questions/37855384/log-httpresponse-body-for-asp-net-core-1-0-rest-api
>
> It works great but cannot be used from SwaggerUI :-(
>
> This may be the reason:
> -----------------------------------------------
> If a middleware reads the request.body stream to the end then subsequent 
> tasks in the pipeline won't get any request.body.
> Therefore, the workaround above reads the body stream to the end and 
> assigns a new stream to the request.body which is positioned at start.
>
> When I look at the Swagger middleware it looks like it reads the 
> context.Request.Body to the end and does not apply the workaround
>
>         private void RespondWithSwaggerJson(HttpResponse response, 
> SwaggerDocument swagger)
>         {
>             response.StatusCode = 200;
>             response.ContentType = "application/json";
>
>             using (var writer = new StreamWriter(response.Body))
>             {
>                 _swaggerSerializer.Serialize(writer, swagger);
>             }
>         }
>
> Has anyone tried to use SwaggerUI on a service layer that has a middleware 
> that peeks at response.body?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to