OData3.1WithSwagger icon indicating copy to clipboard operation
OData3.1WithSwagger copied to clipboard

Missing Formatter

Open AlbertoMonteiro opened this issue 4 years ago • 1 comments

This is the current code https://github.com/hassanhabib/OData3.1WithSwagger/blob/a9af138a5001f921f3c3fd4427767f33fd985fe9/WeatherAPI2/Startup.cs#L77-L87

But for me only worked in this way

services.AddMvcCore(op =>
{
    foreach (var formatter in op.OutputFormatters.OfType<ODataOutputFormatter>().Where(it => it.SupportedMediaTypes.Count == 0))
        formatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/odata"));

    foreach (var formatter in op.InputFormatters.OfType<ODataInputFormatter>().Where(it => it.SupportedMediaTypes.Count == 0))
        formatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/odata"));
})

AlbertoMonteiro avatar Mar 15 '20 20:03 AlbertoMonteiro

Also had this exact problem.

Fixed it with the code from this package: https://github.com/KishorNaik/Sol_OData_Swagger_Support/blob/master/V5.0/Sol_Demo/OData.Swagger/Services/OdataSwaggerSupportServiceExtension.cs

tamaw avatar Jan 19 '21 00:01 tamaw