OData3.1WithSwagger
OData3.1WithSwagger copied to clipboard
Missing Formatter
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"));
})
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