title: Failed to load API definition
body: <p>I have a simple ASP.NET Core API where I have a controller which was supposed to work with an input parameter of HttpRequestMessage.
  I tried the standard formatters and they did not work:</p>
  
  <pre><code>  services.AddMvc(options =&gt;
          {
  
               options.RespectBrowserAcceptHeader = true;
  
               options.InputFormatters.Add(new XmlSerializerInputFormatter());
               options.OutputFormatters.Add(new XmlSerializerOutputFormatter());
  
          }
  </code></pre>
  
  <p>Also tried this formatter:</p>
  
  <pre><code>XmlDataContractSerializerOutputFormatter
  </code></pre>
  
  <p>And it did not work neither.
  So as result, I end up with a custom formatter:</p>
  
  <pre><code>public class RawInputFormatter : InputFormatter
  {
      public override Boolean CanRead(InputFormatterContext context)
      {
          return true;
      }
  
      public override async Task&lt;InputFormatterResult&gt; ReadRequestBodyAsync(InputFormatterContext context)
      {
          if (context == null)
              throw new ArgumentNullException(nameof(context));
  
          var request = context.HttpContext.Request;
          using (var reader = new StreamReader(request.Body))
          {
              try
              {
                  var content = await reader.ReadToEndAsync();
                  return await InputFormatterResult.SuccessAsync(content);
              }
              catch
              {
                  return await InputFormatterResult.FailureAsync();
              }
          }
      }
  }
  </code></pre>
  
  <p>And consequently had to change the input parameter type from HttpRequestMessage to [FromBody]string</p>
  
  <p>And I am being able to read the input xml after this change.</p>
  
  <p>BUT</p>
  
  <p>Now when I start the API (and I use Swagger), the Swagger's screen contains the error message: Failed to load API definition</p>
  
  <p>And it's for all the controllers in the API I have.</p>
  
  <p>I googled but did not find anything valuable. Please advise. </p>